Dear ROOTers,
I would like to create several trees in a program neither leaking memory nor causing segfaults. Unfortunately I do not manage to get rid of the segfaults...
The following is not the program I want to run to create the trees, just
the calls in the same order. For now I just would like to know if:
-this is the right order of calls?
-there is anything missing or too much? (like SetAutoDelete or so)?
// ================================================================= TFile* fFile = 0;
void SetOutputFile( const char* filename ) {
if( fFile ) {
fFile->Write(); delete fTree; fTree = 0; fFile->Close(); delete fFile; fFile = 0;
fFile = new TFile( filename, "recreate" ); fTree = new TTree( "T", "tree" ); fTree->Branch( "event", "TreeEvent", &e, 16000, 2 );
int main()
{
e = new TreeEvent();
for( int i=0; i<100000; ++i ) {
SetOutputFile( "fileXY.root" ); for( int j=0; j<10; ++j ) { /* fill event in 'e'... */ fTree->Fill(); }
// =================================================================
Thanks for your help,
Alexander Received on Tue Jan 17 2006 - 13:50:51 MET
This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:56 MET