Re: Memory leaks?

From: Ilka Antcheva <Ilka.Antcheva_at_cern.ch>
Date: Wed, 24 Aug 2005 18:02:16 +0200


Hi Giorgio,

Your observation is correct about the results given by gObjectTable->Print(). Some of the reasons are memory leaks that we try to fix asap. Why the objects' number vary in a way you see I do not know. Anyway, I will not say that this method is useless because once you know the design of your application, you can check for the object created by it.

If you add objects the following way:

mdiFrame->AddFrame(new TGTextButton(mdiFrame, new TGHotString("&Pressme!"), 1),

                   new TGLayoutHints(kLHintsCenterX | kLHintsCenterY));

you should use the method Cleanup() of TGCompositeFrame, i.e. mdiFrame->Cleanup() will do the job.

Please note: it will delete all objects added to this composite frame via the AddFrame() method. All objects (frames and layout hints) must be unique.

Cheers, Ilka

Giorgio De Nunzio wrote:

>Hi all!
>Another question for you kind gurus..
>I do not understand what ROOT objects in a program should be deleted and
>what should not because they
>already are implicitly.
>
>Take, for example, guitest.C
>I issued gObjectTable->Print() before .x guitest.C and after exiting it, and
>the object
>counts differed, giving 5492 before, and 6523 after execution
>(I simply launched guitest, then I immediately exited calling no menu item
>etc).
>Does this not mean menory leaks?
>
>Another strange thing: start root (5.0.2 in my case) and give
> gObjectTable->Print()
>You obtain some value for total cts.
>Call Print() again: you get (at least I do!) different figures; in
>particular I get 3045 the first time, 3151 the second time (and the
>following
>ones). If I try it again (exit root, start it again, Print, Print), in
>general
>these figures change.
>Why??
>
>OK, I said, I issue this command once, then I throw this result (perhaps
>ROOT
>creates some objects the first time I issue a command), I Print again and
>use
>the latter values to check my programs.
>
>Now, try this one:
>root
>gObjectTable->Print() (I get cts = value1)
>.x basic.C
>gObjectTable->Print() (I get cts = value2, far larger, of course)
>gObjectTable->Print() (I get cts = value3, lower than value2 but different
>from value1)
>gObjectTable->Print() (from now on I get cts = value3)
>
>Any explanation?
>
>Another example, simply creating and destroying some objects:
>
>Print() gives 3041
>Print() again gives 3150
>Print() again gives 3150 (stable, so begin experimenting)
>TCanvas *c = new TCanvas
>Print() gives 3791
>Print() again gives 3834
>Print() again gives 3834 (stable)
>delete c
>Print() gives 3558 (why not 3150?)
>Print() again gives 3558 (this time it is immediately stable)
>
>Another test (continuing the preceding one):
>
>TCanvas *c = new TCanvas
>..3837
>..3838
>..3838
>delete c
>..3561
>..3561
>..3561
>
>And so on..
>You can see that I cannot use gObjectTable->Print() to check if there are
>memory leaks.
>Is it my problem or is there an explanation?
>
>Another question (same sort of problems):
>
>when I issue a command like
>
> mdiFrame->AddFrame(new TGTextButton(mdiFrame, new TGHotString("&Press
>me!"), 1),
> new TGLayoutHints(kLHintsCenterX | kLHintsCenterY));
>
>am I sure that all those "new" stuff are deleted when the frame is deleted?
>I cannot delete them by hand because they have no name..
>
>Thanks!
>Giorgio
>
>-------------------------------------
>Dr. Giorgio De Nunzio
>
>Dipartimento di Scienza dei Materiali
>Universita' di Lecce
>
>tel. 0832 297545
>fax 0832 297548
>
>giorgio.denunzio_at_unile.it
>
>
>
>
Received on Wed Aug 24 2005 - 18:03:25 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:12 MET