On Apr 20, 6:07 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
> Marcelo Fernandez wrote:
> > I was wondering if there is tool that could tell me if some of my
> > pointers are still alive when they are suppose to be dead (in case I
> > forget to kill them...).
> > As you have noticed, I am real newbie in c++ programming and I have
> > quite a trouble to remember which pointer should be alive and which
> > one should die (Java garbage collector fault...).
> There are two approaches: either learn to manage their lifetime
> or use a garbage collector. There are rules for managing lifetime
> of dynamic objects, and I bet books talk about them (like ownership,
> reference counting...), you just need to find the right book. As
> for garbage collector, there are several implementations on the
> market, just look for them.
> There are no tools that can tell when the pointer "are suppose to be
> dead". There are tools that can identify memory that has never been
> deallocated after the program has finished running. Those are called
> "memory leak detector". Look them up.
Most such tools can also find dangling pointers---pointers to
memory that you have already freed. The two that I'm familiar
with are Purify (excellent, but definitly not priced for student
use), and valgrind (worked well the only time I used it, but
I've not enough experience with it to say more).
--
James Kanze (Gabi Software) email:
Conseils en informatique orient閑 objet/
Beratung in objektorientierter Datenverarbeitung
9 place S閙ard, 78210 St.-Cyr-l'蒫ole, France, +33 (0)1 30 23 00 34