[ROOT] Questions on TGeometry

From: Glen R. Salo (gsalo@mrcstl.com)
Date: Mon Jun 04 2001 - 22:34:31 MEST


Hi Rooters!

I have two questions for TGeometry.

1.  I have a need to Clone a TGeometry object.  However, the manner in
    which I use it is giving me a memory leak.  I've included a simple
    example of my problem below.  Can someone inform me what I'm doing
    wrong (as I did not expect the following script to cause a memory
    leak)?  (I am running the latest CVS version of ROOT on RedHat 7.1).

        void gTest() {

          TFile f("na49.root");
          TGeometry *g = (TGeometry *)f.Get("na49");
          Int_t i=0;
          TGeometry *g2;

          //  Memory leak occurs when I do something like the following:
          while (i++ < 4) {
            g2 = (TGeometry *)g->Clone();
            delete g2;
          }
        
        }


2.  The destructor for TGeometry appears to have a potential memory leak
    to me.  The destructor has as its first line of code,

    if (!fMaterials) return;

    However, since it is possible to generate a TStructure without a
    Materials list, it would appear that the fMatrices, fShapes, etc,
    lists internal to TGeometry would not be deleted when no materials are
    defined.  Am I intrepreting this correctly?


Thanks for your help,

Glen

*********************************************************************

Glen R. Salo                                   gsalo@mrcstl.com
Mission Research Corporation                   (314)236-5007
1001 Craig Road, Suite 330                     (314)872-2170 Fax
St. Louis, MO 63146

*********************************************************************



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:47 MET