18.04.2013, 14:19
Quote:
OK, I didn't mention that I'm not allocating small blocks from the heap - I just allocate one huge (several Mb) block once, then allocate from within there. I don't have benchmarks; I can get some but I'm not sure what you want benchmarking - the "malloc" function? Because of the way the code works, actually using the allocated memory is just the same as a standard array access and an addition.
As for fragmentation, that is an issue I've not been able to deal with because I'm currently using direct pointers rather than indirect ones. I could change model and then I could do compression and just update the indirection array, but obviously then you have more code involved (I could make it an option I suppose). The allocation algorithm is the most basic one too - it just allocates from the first free block of sufficient size, there is also "smallest" and "largest", which allocate from the closest matching or most free blocks - it would be interesting to see how they affect fragmentation. "free" is clever though and can merge adjacent blocks when they are both free to give a larger block from which to allocate. |
Can people allocate more memory than those "several Mb"?