Page 1 of 1
memory manager
Posted: Thu Sep 08, 2005 11:00 pm
by dozerl
I have finally gotten to the point of being able to add a memory manager. But the problem is that I don't know where to start. What excalty do I need to be able to get a fully functional mm? I belive I need to make a malloc()/free() function. But I could be wrong. There might also be other parts that I'm unaware of. Any help about where to start or what to do would be grealy apprcitated. Thanks in advanced.
Re: memory manager
Posted: Thu Sep 08, 2005 11:00 pm
by carbonBased
I initially started making my own memory manager... kept two stacks of pages and would maintain a large heap by adding or subtracting pages to the top of the heap.
This worked... but the more I tried to optimize it's speed and minimize its fragmentation, the more I realized I was duplicating effort. Not long after I switch to using Doug Lee's malloc() code (search for dlmalloc).
Not only is dlmalloc (and dlfree) an efficient and useful memory management code-set, but it's also in the public domain.
In order to use dlmalloc all you really need to define are a couple standard unix headers, some #defines, a couple unix error codes, and either sbrk() or morecore().
Then, set the appropriate defines in the header file and you're off. Instant plug-in memory management (allowing one to focus on much cooler aspects of their OS).
--Jeff
Re: memory manager
Posted: Fri Sep 09, 2005 11:00 pm
by dozerl
Thanks, I'll try that later on today.