Memory Management?

Started by
15 comments, last by emblemstuart 20 years, 10 months ago
(emblemstuart again)

Dumping a memory pool to save a game seems like a particularly bad idea. The savegames will end up bloated from saving redundant or unecessary information, and you risk not saving all the data you need if you''re using a 3rd party library with internal state (LUA for instance). You don''t have much choice except to handle 3rd party state as a special case. As far as saving your own state goes why no have virtual to/from data stream functions for your game state objects? It''s easy to implement (as a single function in a commom base class) and easily refineable when you want to avoid saving unneeded data.

Stuart
Advertisement
on PS2 you want FAST loading times. and PS2 is excellent at streaming huge chunks of data from the dvd-rom, where you have tons of space. It totally makes sense to dump a complete game state to disk and just load it in with a single read operation.
If you are under Windows, look into the Heap functions provided by the API. Also, I have created a nice class called CHeap (no pun intended) that has overloaded new and delete operators. I built my class of the information in Jeff Richter's book titled Advanced Windows Programming...

I derive all my GameObject classes from CHeap which gives me a heap of memory for all objects of the same type - this allows the heap properly allocate the proper ammount of memory for the new and delete operations.

I can provide my source to anyone that is interested...

Dave "Dak Lozar" Loeser

===
I misspoke about the class - you can't inherit from it as I said. The reason for this is that the class has two static members that need to be specific to the class that you are using the heap for…

[edited by - Dak Lozar on June 19, 2003 11:24:32 PM]
Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
Id be intrested in having a look Dak Lozar, although my engine is a far way off from needing speed boosts like that it cant hurt to get an idea now can it? Seems like an itneresting topic.

email Drazgal@deadpan-studios.co.uk
Hehe, interesting for this thread to come up today. I just implemented a memory manager test with this style. Only worked on it for about an hour or so and it''s really just a test program. I also wanted to play around with overloading new and delete and implementing singletons.

One minor advantage is easy memory dumps. You can just dump the contents of your memory blocks into a file. You can of course do this without your own memory manager, but it''s more difficult.
Game Programming Gems has an article on this sort of thing, the author refers to ''frame based memory allocation.'' Or just have a look at zone.c in the Quake 1 source code.

------------
- outRider -
Dak Lozar: I am interested aswell gothmog2k@web.de

[edited by - Hazelnuss on June 20, 2003 3:11:25 PM]

This topic is closed to new replies.

Advertisement