Enginuity memory management

Started by
2 comments, last by Mulligan 19 years, 8 months ago
I'm browsing through all the Enginuity source code, and I found that all of a sudden, the base memory management class completely changes. I'm trying to figure it out on my own, but its just to much at this point. Does anyone know of some kind of explanation of the new code? EDIT: that was kind of a odd question, so how about this: What is HeapObjects ? What is IsStackAllocated?
Advertisement
int array[100]; <-- Stack allocatedint array = new int[100]; <-- Heap allocated


Hmm.. Look here:
LINK

Short: stack allocated objects is deleted when they get out of scope, while heap allocated objects stay allocated until freed (either by C++ delete or stdlib free())
Ok.. Think I misunderstood that question... Downloaded the source and had a look through it and this is what I saw:

Everytime a new object is created from a class that is derived from IMMObject either on the heap or on the stack, the "instance" of it get stored in the std::list. When finishing up and running the 'garbage collector' function you might end up deleteing thing that should not be deleted -> stack allocated object. Superpig overloaded the new operator to keep track of wich objects that were allocated on the stack, avoiding to pull of an invalid delete upon them. Guess I'm not that great tutor [smile]
ok, thanks. that helped

This topic is closed to new replies.

Advertisement