Program hangs when trying to save very long TClonesArray

Hello ROOTers,
I have a program that uses ROOT’s I/O methods for saving to/reading from disk. My setup is as follows: I have a Storage class that contains an stl vector of TClonesArray pointers (I create a new TClonesArray for each object type in the program). I let ROOT take care of the generation of the Streamer for this class, and simply save/retrieve it to/from file using the TFile::WriteTObject() and TFile::Get() methods. This has worked beautifully for me for the past couple of years, but recently I have been trying to write files that have rather large TClonesArrays (O[10^6] elements). There seems to be a maximum number of elements I can have (~3.1 x 10^6), after which my program hangs when trying to write these TClonesArrays to file. I have traced the hang to the call

((TObject*)obj)->Streamer(*fBufferRef); //write object

in the TKey constructor, and don’t really know how to proceed. Any help would be greatly appreciated!


As an update, I have modified my saving/retrieval algorithms to store and read from a TTree, and have placed my TClonesArrays as branches on this tree. This works without a problem with file sizes that caused the previous methods to hang, so maybe the error that arose from storing TClonesArrays directly had to do with memory management (which TTrees handle better, I think?).


The maximum size that can be stored in a single key is 1Gb of data, you are likely to be reaching this limit in your original case. Moving on to TTree is a the right and much better solution.