memory manager

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
dozerl
Posts: 19
Joined: Tue May 10, 2005 11:00 pm
Location: here

memory manager

Post 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.
User avatar
carbonBased
Member
Member
Posts: 382
Joined: Sat Nov 20, 2004 12:00 am
Location: Wellesley, Ontario, Canada
Contact:

Re: memory manager

Post 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
dozerl
Posts: 19
Joined: Tue May 10, 2005 11:00 pm
Location: here

Re: memory manager

Post by dozerl »

Thanks, I'll try that later on today.
Post Reply