Dear Rooters I am writing code which I compile as library "Mylib.so". I am used to create my objects with "new obj" and delete them after use with "delete obj". However, when using root, in the following cases I am not sure what to do: 1, "obj = gDirectory->Get("name");": Does this create the object or do I have first to call "obj = new TObject"? Do I have to call "delete obj" afterwards? 2, "tree->MakeClass("MyClass");": When I have "tree->Branch("br","ClassA",&classA,64000,0);" and call MakeClass, then the automatically generated code "MyClass.h" uses TTree, TBranch, ClassA without creating any of these classes first. When I use this code in my library code, do I have to create these classes first? At the moment my code creates these classes in a constructor (new TTree, new TBranch, new MyClass) and calls "delete tree, delete br, delete classA" in a destructor. This code works fine, nevertheless my question is: Is this the correct way to do? Do I create a memory leak by doing this? Is it not necessary to create these classes? At last a general question: How can I test whether my code produces memory leaks? Thank you in advance for your help Christian ---------------------------------- C.h.r.i.s.t.i.a.n S.t.r.a.t.o.w.a V.i.e.n.n.a. A.U.S.T.R.I.A e-mail: cstrato@EUnet.at
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:36 MET