Memory Manager | Sololearn: Learn to code for FREE!


Memory Manager

Hey. I made this simple memory manager and was wondering if anyone has experience in this field. Specifically I want to learn how to avoid fragmentation and such.. If I make each entry a fixed size (larger than anything stored), will this fix any fragmentation issues?

8/11/2017 3:44:54 AM


7 Answers

New Answer


fair enough 😊 it is for learning game programming mostly. i have read that pretty much all "large" games utilize custom memory managers. it probably overkill but at least I will know how it is done for future reference


Speed and to ensure there is enough memory on execution at runtime for the program to run. I hear tell memory allocations can be a bottleneck. so to alleviate this we can grab a big chunk of memory at execution and fill that as required. If this chunk gets fragmented over time we may/will end up with spaces that can not be filled with anything and therefore is essentially lost.


i found this i am going to try. thought i'd leave it here for anyone who might be interested


but fragmentation will still occur will it not?


I understood the point, but I think it is too much work for it. If my program has to allocate and relocate memory frequently to some class object, I would just create an object in the outer scope and use a function to reinitialize it instead of creating a new one.


Check something named RAII and smart pointers. If you learn to use those, you won't worry with memory leaks anymore.


Sorry, I fail to see any benefit in avoiding memory to get fragmented. Can you explain what you need that for, please?