I have a class that contains a TClonesArray of another class. The destructor on the class is working fine; I can loop indefinitely creating, populating, and then deleting the class without any increase in memory usage. When I write the class to disk using a TTree and then read it back the memory increases steadily until root crashes. The TClonesArray is allocated in the default constructor but if I remove this then I get a segfault during TTree::GetEntry.
The TTree documentation lists three methods of ensuring objects are deleted after TTree:GetEntry is called. If I let TTree handle it by itself or use ‘branch->SetAutoDelete(kTRUE);’ (options 1 and 2) then I see that my class’s destructor is not called and memory is leaking. If I do option 3, which is ‘delete class_pointer; class_pointer = 0;’ after each GetEntry then I get a segfault inside of the second GetEntry call.
Am I missing something here? Is this an issue with using ROOT 5.22.00 (against my will)?