|
|
| Author |
Message |
GTBecker
Joined: 18 Jan 2006
Posts: 472
Location: Cape Coral
|
|
Posted: 17 September 2006, 15:48 PM Post subject: Allocating a variable length array |
|
|
| Quote: | ... fails because there is not a single contiguous block of free memory...
|
The same situation occurs in file management. Defrag became a verb when
Microsoft made us do it. XP does it continually. All you need is a
hyper-speed memory manager that runs transparently.
Can you have that by Tuesday, Don?
Tom |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR
|
|
Posted: 17 September 2006, 16:13 PM Post subject: Re: Allocating a variable length array |
|
|
| GTBecker wrote: | | The same situation occurs in file management. |
Although the idea is similar, it's not quite the same thing. With disk space allocation, there is usually a virtualization layer that maps the contiguous sequence of bytes that comprise a file to the possibly discontiguous sectors on the disk where the bytes are actually stored. Fragmentation on a disk doesn't stop one from creating a file that uses the fragmented space, it just results in lower performance than could be obtained if the file were stored contiguously.
Although you could implement a similar virtualization layer for a memory allocator, I suspect that performance limitations would outweigh the benefit.
As is commonly done, the ZX allocator does combine adjacent free blocks in order to create the largest possible free blocks for future allocation requests. |
|
| Back to top |
|
 |
stevech
Joined: 23 Feb 2006
Posts: 688
|
|
Posted: 17 September 2006, 17:28 PM Post subject: |
|
|
does the VM's memory allocator try to merge returned adjacent blocks? I know this can get messy and time-consuming.
For our humble micros, I think it's best to use small blocks and don't vary the block size much. |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2593
Location: Portland, OR
|
|
Posted: 17 September 2006, 17:48 PM Post subject: |
|
|
| stevech wrote: | | does the VM's memory allocator try to merge returned adjacent blocks? I know this can get messy and time-consuming. |
It does. It's not particularly difficult to do since, at most, three blocks need to be combined.
The heap is automatically expanded and contracted, too, as need be. The UnsignedInteger value Register.HeapEnd indicates the lowest address in the heap which grows from higher addresses toward lower addresses. |
|
| Back to top |
|
 |
|