Re: [ROOT] gROOT->Reset() behaviour

From: Damir Buskulic (buskulic@lapp.in2p3.fr)
Date: Tue Oct 03 2000 - 11:05:13 MEST


Hi,

That's why I was confused. Obviously, I still lack this course...
Anyway, even if I perfectly understand why it's impossible to change
this behaviour, it is annoying to have a strongly suggested way of
cleaning the interpreter environment, when in fact the user himself has
to clean some of the objects he created. I know it is basic programming
practice but in the interactive session, this may be a problem.
Imagine you create several histograms interactively via new, you will
not be able to work a few hours without restarting your machine because
you (in fact I) fill the memory little by little. I know I should build
static objects instead of using new but every small script uses new. And
executing again and again such small scripts does exactly the symptoms
above if one is too lazy to think absolutely every time to delete his
heap objects at the end of his script.
Well, Is it really impossible, or is it going to slow down the
interpreter to take care of the objects allocated via new and be able to
clean completely the memory. This is certainly not the way a C compiler
works but it would ease the everyday use. There are certainly obvious
cases I miss where this is not applicable. Which ones ?

Sorry if all this discussion is like going back in time but I think
these simple cases make some people feeling uneasy about the
interpreter, when they were used not to bother about pointers, memory
and so on. I think it's really a matter of user friendlyness.

Cheers

Damir 

Paul Balm wrote:
> 
> Hi!
> 
> You'll probably get a lot more educated asnwer from somebody else on the
> list, but at least I'm quick.
> I'm very new to ROOT, so I still remember things from my course. :-)
> gROOT->Reset() clears objects created on the stack, and as you know, the
> operator new creates an object on the heap.
> I hope I remember correctly, but it looks like that's the problem. Enter a
> line
> delete vd;
> in the destructor of the class that's creating this object. That should
> help.
> Cheers,
> 
> Paul
> 
> Damir Buskulic wrote:
> 
> > Hi,
> >
> > I know this ubject has been discussed many times but I'm a little bit
> > confused by the behaviour of gROOT->Reset(). It is supposed to clean all
> > global variables in the interpreter environment. But when I build a new
> > object of mine :
> > vd = new VFrDataBase("demoDB.root")
> > and issue a gROOT->Reset() after this, for example by running a script
> > containing gROOT->Reset() as the first line, a few times, it is obvious
> > that the object vd, though removed from the interpreter environment, and
> > though global, is not deleted. The memory is not freed and everything
> > happens as if there was a memory leak.
> > What is happening ? When is an object effectively deleted by a
> > gROOT->Reset() ?
> > I do understand the necessity to not delete some objects (such as a
> > Canvas for example) but how do I specify that an object can be deleted ?
> > I tried SetBit(kCanDelete) to no avail.
> >
> > Any explanations/hints ?
> >
> > Cheers
> >
> > Damir
> > --
> > =====================================================================
> > | Damir Buskulic                  | Universite de Savoie/LAPP       |
> > |                                 | Chemin de Bellevue, B.P. 110    |
> > | Tel : +33 (0)450091600          | F-74941 Annecy-le-Vieux Cedex   |
> > | e-mail: buskulic@lapp.in2p3.fr  | FRANCE                          |
> > =====================================================================
> > mailto:buskulic@lapp.in2p3.fr
> 
>   ------------------------------------------------------------------------
> 
>   Paul Balm <p.balm@nikhef.nl>
>   Fermilab (NIKHEF)
>   DZero
> 
>   Paul Balm
>   Fermilab (NIKHEF)  <p.balm@nikhef.nl>
>   DZero
>   PO Box 500         Fax: ++ 1 630 840 8886
>   Batavia            Home: ++ 1 630 933 8857
>   IL                 Work: ++ 1 630 840 2177
>   60510
>   USA
>   Additional Information:
>   Last Name       Balm
>   First Name      Paul
>   Version         2.1

-- 
=====================================================================
| Damir Buskulic                  | Universite de Savoie/LAPP       |
|                                 | Chemin de Bellevue, B.P. 110    |
| Tel : +33 (0)450091600          | F-74941 Annecy-le-Vieux Cedex   |
| e-mail: buskulic@lapp.in2p3.fr  | FRANCE                          |
=====================================================================
mailto:buskulic@lapp.in2p3.fr



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:34 MET