Skip to main content
gamedev.net
🔒 Locked

Memory management

Started by ivquatch Oct 17, 2003 at 9:26 PM 3 replies 1.2k views
Original Post
ivquatch
ivquatch
Anyone know of a good tutorial on how to write a memory magament system ala doom or quake? I''ve been reading through the doom src and have a general idea of how it should work, but am looking for some good documentation to make like easier.
Pseudo
Pseudo
That is a very vague question. What is your memory management system going to be used for? A solution could range from simple reference counting to a full garbage collector. It all depends on what it''s for. From what I''ve read of the quake (quake 2 at least), I dont suggest using it as much of a reference for anything modern. Both quake and doom were designed to run on a 486 with very limited memory. Today, you can get away with pre-allocating large blocks of memory at load time and not worrying about whether or not your 101''th mesh will fit into ram.

Unless you''re having performance problems, just use new and delete for allocation (assuming C++ here), and possibly simple reference counting.
ivquatch
ivquatch
Yeah you''re probably right. I was just planning on reference counting and allocating a big (logically) contiguous block of memory for my game objects and other such crap. I really just wanted the application to sit nicely in it''s own fixed block of memory. I just read an article at www.memorymanagemnt.org and for all intents and purposes, I''d be better of just going with new/delete.
SteveK
SteveK
I think you would be better off not using any type of memory allocation. Make all your stuff global. Even though your exe might seem quite large it really shouldn''t matter. With the RAM that the machines have these day''s it doesn''t really matter if your exe is 256K or 100MB. Plus shuffling around through a hunk of RAM is a PITA ( pain in the @$%$). Save yourself the headache of keeping track of starting addresses and lengths and avoid manually allocating memory.
Kylotan
Kylotan
It''s nice to use STL structures like vectors and lists because not only do they manage the memory for you, they also try hard to do so in an intelligent way that reduces fragmentation and increases speed. For example, adding 100 elements to a vector won''t resize it 100 times, even though it''s managing the memory for you.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.