Sign in to follow this  
Mulligan

Enginuity memory management

Recommended Posts

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?

Share this post


Link to post
Share on other sites

int array[100]; <-- Stack allocated
int 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())

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this