Skip to main content
gamedev.net
🔒 Locked

Memory Management ...

Started by P3D-BrandonR 5 replies 1.1k views
Original Post
P3D-BrandonR
P3D-BrandonR
I know this is a pretty bland topic but I'm a little confused and need some direction. I have in place a nicely done Resource Manager if you will, keeps track of how many references an object (such as a texture) has and knows when it should be deleted or freed. The question I have is, I've read and seen in engines where they have a memory manager in place as well. That deals with actually holding bits of pre-determined memory allocated in say certain size blocks and things like that. I geuss what I'm asking is having something like that kind of memory manager really required ? If so is there some links or references to some better studies on this topic ? I have 4 books that contain it but I'm trying to get more feedback and ways of doing it so to speak so I can learn every angle of it. Sorry to be so n00bish in this question, it's the one basic system I have left to really get a grasp on. -Brandon
templewulf
templewulf
That kind of anal-retentive memory management is completely unnecessary on a modern PC. In handhelds, consoles, and PDAs, you really do need to tightly control everything that happens in your code.

Even though PC gamers are spoiled by huge memory heaps and virtual memory, you still don't want your code to bloat, or worse, to leak! The extent of memory management you need might just be a custom smart pointer. I believe superpig's Enginuity articles deal with that, so you might want to look them up in Articles and Resources.
XBox 360 gamertag: templewulf feel free to add me!
Palidine
Palidine
Quote:
Original post by templewulf
That kind of anal-retentive memory management is completely unnecessary on a modern PC.


For professional PC titles this is 100% incorrect.

Even on a modern PC, the difference in performance of a fully fragmented memory footprint and a nice managed memory footprint are staggering. I've worked on a title that had no memory management and if you let it run for more than 1.5 hours the framerate would gradually drop from ~60 to ~10 largely from memory fragmentation.

-me
jpetrie
jpetrie
Quote:

The extent of memory management you need might just be a custom smart pointer.


Except since he's not on a limited platform and effective, robust and (most importantly!) correct smart pointers are not trivial, he'd probably be much better off using Boost's smart pointers.

Having no memory management is better than having broken memory management that you trust because you don't realize it might be broken.

[Edited by - jpetrie on May 15, 2006 5:43:44 PM]
UBrothers
UBrothers
Oh man, what are you doing ? Do you have complete engine already and just optimizing things ? If not, then focus on something more important than custom memory manager. I am not using custom memory manager in our game and there are no problems! Even after long time of game running there are NO framerate drops.

I think that if framerate drops from 60fps to 10fps after a hour of playing a game - then there must be some other problem (like leaking memory ....)
The Reindeer Effect
The Reindeer Effect
Here are two good reads for all of you interested in memory management:

Dynamic Storage Allocation: A Survey and Critical Review
Uniprocessor Garbage Collection Techniques

The first will likely be more appropriate for you, since writing a high performance garbage collector is nontrivial and if your working language is C/C++ you are limited to conservative mark/sweep techniques. (In which case, you should just go ahead and use Boehm's GC.)
CrazyCdn
CrazyCdn
Quote:
Original post by UBrothers
Oh man, what are you doing ? Do you have complete engine already and just optimizing things ? If not, then focus on something more important than custom memory manager. I am not using custom memory manager in our game and there are no problems! Even after long time of game running there are NO framerate drops.

I think that if framerate drops from 60fps to 10fps after a hour of playing a game - then there must be some other problem (like leaking memory ....)


Exactly why you want a memory manager to track this for you. If you suddenly develop a leak how long will it take you to debug it? Took me 10 hours so far to impliment a kick butt memory manager from scratch that posts to a log file the file name, function name and line number the leak occured in.

And with Fluid Studios having a free ready to drop in memory manager there is no excuses now-a-days for these sort of things NOT being used. Then again you can technically drop it in later but why not do it now and forget about it?
"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

Topic Locked

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

Sign in to reply to this topic.