Archived

This topic is now archived and is closed to further replies.

BIOSME

Memory Fragmentation

Recommended Posts

Should I worry about memory fragmentation when developing games for Windows and make a heap mangement system of my own? or is it one of the Windows'' responsibilities to take care of this? Thanks.

Share this post


Link to post
Share on other sites
Windows (and the CRT memory manager) *will* handle cases of serious fragmentation. However you should try and prevent fragmentation yourself where possible since the corrective measures Windows will take in cases of *serious* fragmentation may end up thrashing the harddisk (reorganising the pages in the pagefile) and stalling your program for up to a few minutes!... (Similar to what happens when you exit a game which has been chewing memory).

You don''t necessarily need to make your own memory manager - just being careful with your allocations can be enough. I''ve worked on commercial games without any specialist memory manager and they''ve been more or less free of problems (although if fragmentation problems were to appear it''d usually take a few hours).

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
What about the one found in Quake src?
It is absolutely a memory manager that handles game data chunks and speeds up performance rather than waiting for system calls to complete.
My advice is that you create an in-game memory system that serves allocation and deallocation requests. Have a look at quake src. There is exactly one malloc call which is used to reserve a large mem pool at initialization time, and from which all chunks are extracted.




Share this post


Link to post
Share on other sites
quote:
Original post by ProgC
What about the one found in Quake src?
It is absolutely a memory manager that handles game data chunks and speeds up performance rather than waiting for system calls to complete.
My advice is that you create an in-game memory system that serves allocation and deallocation requests. Have a look at quake src. There is exactly one malloc call which is used to reserve a large mem pool at initialization time, and from which all chunks are extracted.







However thats Quake. Which was written by John Carmack. Unless you feel like adding a ton of possible bugs and other complexities for a possible 0.5fps increase (There are so many other easy places you could optimize first and get much better results) and reduced chance of fragmentation over the long run that I doubt its worth it.

[Edit] Remember, just because Quake has it doesn't mean that every hobby developer should(or needs) to have it (Quake 1 was software mode 3D, Quake 2 had a carmack optimized software 3D engine which only required about 50mhz more power than the hardware 3D mode, does this mean you need to spend 2-3 years of your life writing a custom software mode engine to replace the DX/OpenGL software mode because they're not fast enough?).



[edited by - Michalson on March 24, 2002 4:05:33 PM]

Share this post


Link to post
Share on other sites
It''s a shame that Windows doesn''t support zones (or, if it does, I''m certainly not aware of it). You could simulate them by taking the Carmack route, though I believe that he customly implemented zones for all platforms, whether or not they natively support zones.

Share this post


Link to post
Share on other sites