Re: Regard to the memory leak in BlastLib2

From: tong@mit.edu
Date: Wed Sep 18 2002 - 17:37:11 EDT


Hi all,

It is not surprising that we have many memory leaks.
We have never optimized the code or debug for memory
leaks.

Because some classes have pointer to pervious classes, especially
in TBLWc1*, deleting just that class might cause memory leak, too.
For some reason, if you need to delete TBLWc1* class, you have to
follow all the way down to hit container class and delete'm all.
What I am saying is that if you just put "delete" for every "new," you
will get run time segmentation error.

-T

Quoting Adam DeGrush <degrush@MIT.EDU>:

> Hello All,
>
> There is a way that ROOT facilitates keeping track of objects created on the
> heap using "new" . One can create a TList container and then add every
> object
> to the container as its created. So for example:
>
>
> //Create a TList
> TList *fTrashCan = new TList;
>
> //An ordinary class
> myClass *A = new myClass;
> anotherClass *B = new anotherClass;
> //Add them to the container
> fTrashCan->Add(A);
> fTrashCan->Add(B);
>
> //When you are done with the object, ROOT will free the memory taken by A and
> B
> in one fatal swoop
> fTrashCan->Delete();
>
> //Then free up memory by fTrashCan
> delete fTrashCan;
>
>
> This may help someone
>
> Cheers,
> Adam
>
>



This archive was generated by hypermail 2.1.2 : Mon Feb 24 2014 - 14:07:28 EST