Basic memory managment questions
Posted: Mon Mar 02, 2009 6:52 am
I'm about to implement a memory manager, but I have a few questions.
1. First of all, should the amount of memory that can be allocated quantized? So it has to be a power of two, even if I waste some of it? I though about having a list of all free blocks of sizes that are powers of two. Or I guess that a block could be of any size and I still store it in list (so in one list I store all blocks that have a size between 2^x and 2^x+1 and so on).
2. Secondly, should I have both a list of freed blocks (this is only blocks that has been allocated once and then freed), and also a pointer to a memory-chunk (which could be of any size) on the end of the heap where I can make new allocations in case I don't find anything in the free-list? Or should I treat the part of memory that hasn't been touched yet as a free chunk itself (stored in the lst)? So the difference is that in the latter I dont distinguish between the highest part of the memory that has never been used, and a block that has been used before and then freed.
Would be nice to see how people does it, the details...
1. First of all, should the amount of memory that can be allocated quantized? So it has to be a power of two, even if I waste some of it? I though about having a list of all free blocks of sizes that are powers of two. Or I guess that a block could be of any size and I still store it in list (so in one list I store all blocks that have a size between 2^x and 2^x+1 and so on).
2. Secondly, should I have both a list of freed blocks (this is only blocks that has been allocated once and then freed), and also a pointer to a memory-chunk (which could be of any size) on the end of the heap where I can make new allocations in case I don't find anything in the free-list? Or should I treat the part of memory that hasn't been touched yet as a free chunk itself (stored in the lst)? So the difference is that in the latter I dont distinguish between the highest part of the memory that has never been used, and a block that has been used before and then freed.
Would be nice to see how people does it, the details...