gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Using a memory allocator on the DS

#137537 - M3d10n - Mon Aug 13, 2007 3:07 am

I need to be able to create independent memory pools to keep specific kinds of data grouped together for easy unloading/reloading without risking memory fragmentation. Like pools for character models, level geometry, sounds, etc.

I've been thinking of using the Lea Allocator on my project. I've read good things about it, but I'm not sure if it'd be suitable for the DS.

I've also found this example of a block-based allocator intendend for the GBA:
http://www.oroboro.com/rafael/docserv.php/index/programming/article/memmgr

Can someone make a recommendation? Thanks in advance.

#137540 - tepples - Mon Aug 13, 2007 3:30 am

For fixed-size blocks, it's hard to beat a pool with a free-element bitmap. How many of each type do you plan to allocate, and how big is each object? And are you using C or C++?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#137573 - M3d10n - Mon Aug 13, 2007 4:51 pm

I'm using C++. This is my initial idea for each pool:

- Runtime objects allocated using new() (player class, object class, scenegraph entries, etc).
- level's display lists
- characters' display lists
- static objects' display lists
- character animations
- sound samples
- text

Textures are going directly to VRAM (but maybe I could treat that as another memory pool?)

I'm thinking of pre-allocating each pool with a pre-determined size when the game loads to limit how much RAM each type of resource can use.