Acorn Arcade forums: Programming: Sliding Heaps
|
Sliding Heaps |
|
Chris (08:06 20/10/2005) David Buck (12:28 31/10/2005) Chris (14:57 31/10/2005)
|
|
Chris |
Message #70771, posted by Chris at 08:06, 20/10/2005 |
Member
Posts: 283
|
I have been using a set of BASIC procedures for some time to allocate blocks of memory using OS_Heap. They are based on an article written by Alan Wrigley in RISC User ages ago, and work very well. However, although they release memory where they can, they don't implement a sliding heap, so with a number of blocks being resized and moved around fragmentation occurs.
I've had a look on the web for any assistance in augmenting my current routines, but to no avail. Googling CSA.Programmer seems to imply such a thing is not possible. There are a lot of modules around which provide this functionality, but what I'd really like is a simple addition to my current library which compacts the heap whenever necessary (e.g. when a block is resized and moved).
So my question is: is there a simple way, using standard SWIs in BASIC, to compact a fragmented heap? If so, could anyone point me to resources which might enable me to implement this?
Thanks.
(But please don't tell me I should be using C! ) |
|
[ Log in to reply ] |
|
David Buck |
Message #71261, posted by David Buck at 12:28, 31/10/2005, in reply to message #70771 |
Member
Posts: 7
|
RiscCAD uses its own heap manager routines to maintain a number of blocks above BASICs workspace. I use 2 routines to do the following:
FNcompact_block - reduce the block to one page size FNextend block - Extend a block by an amount
I can let you have copies of these if you email me. The system can handle any number of blocks, and when expanding blocks it moves the relevent memory up or down, such that an array variable always points to the start of the blocks.
ie if you have 8 blocks, DIM memo_start%(, then memo_start%(1) points to the start of block 1 etc. memo_size%(1) gives the size of the block. |
|
[ Log in to reply ] |
|
Chris |
Message #71272, posted by Chris at 14:57, 31/10/2005, in reply to message #71261 |
Member
Posts: 283
|
Thanks David - that sounds interesting. I will drop you a line at the address on your website (which looks very nice, btw ). |
|
[ Log in to reply ] |
|
|
Acorn Arcade forums: Programming: Sliding Heaps |