Re: Root files, directories & objects - WinNT (pt 2)

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Dec 02 1999 - 15:31:22 MET


Hi Mariusz,
It is difficult to come with a diagnostic without more information.
You do not mention how many keys you have created (10, 10 millions ?)
What is your estimation of your "claimed leak" wrt the number of
objects written ?
Could you use the Root utility showing the number of objects
in memory for each class.
   with  gObjectTable->Print();
You must #include "TobjectTable.h" and make sure that
the memory statistics flag is activated in your .rootrc
When you write an object to a file via obj->Write
a TKey object is created in memory (about 70 bytes). The current directory
holds a list of TKeys. In case you have many objects in a directory
this can consume a lot od space in memory. That is why we came with
TTrees. TTrees are designed to support millions of objects with a minimum
memory overhead.

Rene Brun

On Thu, 2 Dec 1999, Mariusz Stanczak wrote:

> Hello,
>    The version 2.23/09 has fixed the problem with the number of directories
> on a root file, but still not all is well.  I write some objects (class
> version of a structure with simple data types) in top level directories on a
> root file.  The class is instantiated, written to a file, and deleted, BUT
> it's memory is never dealocated.  Consequently the system memory is
> exhausted resulting in a system hang.  I tried doing f.Flash(), f.Write()
> with no change.  Only f.Close() works.
>    I'm not sure it's a pertinent observation, but my code is the same, and
> under the previous version of Root even though the memory was being used up
> and accumulated just as it is now (despite the immediate deletes), it was
> all being freed up at once as if there was a garbage collection done right
> before the crash (caused by the large number of directories), now
> (obviously) I do not observe such activity.
>    There seems to be no mechanism to force root file (or Root) to flush it's
> buffers (or is there?).  All the methods that I found to facilitate this
> have been applied to TTrees and not to TFile, and that's all I have...
> TFile, TDirectory, and a simple class object.  What to do?  Anything... it's
> desperate time for this project and it's use of Root.
> 
> Thank you,
> /Mariusz
> 
> P.S.  It's all under WinNT 4sp5 and VC++ 6sp1
> 
> ---- the code ----
> 	while(fgets(l_in, 120, f_in)) {
> 		sscanf(l_in, "%s %s %f %f %f %f %d",
> 			t, d, &fo, &fh, &fl, &fc, &fv);
> 
> 		if (strcmp(t, prev_t) != 0) {
> 			gDirectory->Write(NULL, TObject::kOverwrite);
> 			strcpy(prev_t, t);
> 
> 			if (!syms->FindObject(t)) {
> 				f_out->cd();
> 				f_out->mkdir(t, " ");
> 			}
> 			f_out->cd(t);
> 		}
> 		D1 = new RPCls(d, fo, fh, fl, fc, fv);
> 		D1->Write();
> 		delete D1;
> 	}
> 	f_out->Write(NULL, TObject::kOverwrite);
> ---- end of code ----
> 



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:43 MET