Re: About Memory Leaks


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

Posted by Dave Longley on April 17, 2001 at 18:02:51:

In Reply to: About Memory Leaks posted by Anthony on April 17, 2001 at 17:52:37:

Make your Creature destructor virtual so it will keep a pointer in its virtual table to the destructor of whatever its pointing at.


: Ok, you dynamically allocate a creature in the Manager class (based on a create command), and insert it into the list through a member function in the Ecosystem class. How would you prevent a memory leak when the creature dies? Look at my situation:

: What is happening in my case is that I'm searching through my list of creature pointers until I find the right creature to "make die." Then I get that element and assign a Creature pointer to it, and try to delete it there. But I get a Debug Assertion Error. If I can't delete it through access in the list, how will I prevent a memory leak?

: ~~Anthony~~




Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]