Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

C memory management

Name: Anonymous 2011-02-12 5:42

Hey /prog, I'm teaching myself C by writing a roguelike and I noticed that C uses manual memory management for creating objects in the heap. I was wondering if the C-gods could lend me some advice on how to proceed with this:

I want to write a roguelike with thousands of NPCs, every NPC is a really small piece of data which does not contain any pointers (position, stats, behavior... probably ends up being a few bytes). NPCs would spawn and die constantly. How would I go about managing the memory for this?

• malloc and free individual NPCs
• Boehm-Demers-Weiser conservative garbage collector
• malloc a big chunk of memory and build some kind of memory manager on top of it (are there techniques for this?)

Please advice.

Name: Anonymous 2011-02-12 16:21

>>31
does contain horrible, misleading code,
How many times have we been over this? The whole point of the post was that misleading code is a problem, of course it contains an example of exactly that. I've explained that a few times already, including the very same post the code appears in.

>>42
FWIW, I had a simulator running ~300,000 object simulations/sec., executing transcendental computations on about 16 different attributes plus branching code running on an ARM chip clocked at 66MHz with no FPU. Unless you plan to do something obscene like solve path finding completely each frame for each entity or get into very high numbers of entities I don't see a problem brewing if you are targeting desktop typical systems with 1920x1080 displays.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List