Dear ROOT developers and users,
I have several questions about macro attached at the end of this mail.
The macro instructions are simple:
w1) open ROOT file for writing
w2) write several TNamed objects in the file
w3) close file
r1) open the same file in "read" mode
r2) read objects back
When objects are written/read to/from file the time of writing/reading
is printed to screen.
Please take a look at the macro and readout from it.
Well, these are my questions:
1) Root increases it size (in memory) on 300 bytes after writing each
TNamed("","") object. Why? If this is correct, is it possible to free
the memory? (May be I need to write 10^7 objects and I do not have 3Gb
of meomry!)
2) The rate of writing/reading drops with time. Why?
With best wishes,
Alexander Zvyagin.
// --- CUT HERE ---
// File b.c
void b(void)
{
char name[111]; // Name of object
int N = 20000, // Total objects amount
update = 5000; // Update rate
TNamed a ("",""); // The object
TBenchmark b; // For printing statistics
// ----------------------------------
printf("Writing...\n");
TFile f1("1.root","RECREATE","",9); // Open file for writing
b.Start("b");
for( int i=1; i<=N; i++ ) // Cycle...
{
if(i%update==0)
{
// Print time of writing last portion of objects.
b.Show("b");
b.Reset();
b.Start("b");
}
sprintf(name,"event%d",i); // Create object name
a.Write(name); // Write object
}
f1.Close();
// ----------------------------------
printf("\nReading...\n");
TFile f2("1.root"); // Open file for reading
b.Reset();
b.Start("b");
for( int i=1; ; i++ )
{
if(i%update==0)
{
// Print time of reading last portion of objects.
b.Show("b");
b.Reset();
b.Start("b");
}
sprintf(name,"event%d",i); // Create object name
TNamed *o = f2.Get(name); // Read next object
if( NULL==o )
break; // Can not read object - finish
else
delete o; // Delete object
}
// ----------------------------------
}
// --- CUT HERE ---
*******************************************
* *
* W E L C O M E to R O O T *
* *
* Version 2.21/08 18 March 1999 *
* *
* You are welcome to visit our Web site *
* http://root.cern.ch *
* *
*******************************************
CINT/ROOT C/C++ Interpreter version 5.13.92, Mar 13 1999
Type ? for help. Commands must be C++ statements.
Enclose multiple statements between { }.
root [0] .x b.c
Writing...
b : Real Time = 1.71 seconds Cpu Time = 1.48 seconds
b : Real Time = 2.11 seconds Cpu Time = 1.90 seconds
b : Real Time = 2.45 seconds Cpu Time = 2.30 seconds
b : Real Time = 3.00 seconds Cpu Time = 2.63 seconds
Reading...
b : Real Time = 20.07 seconds Cpu Time = 19.04 seconds
b : Real Time = 62.75 seconds Cpu Time = 60.52 seconds
b : Real Time = 103.11 seconds Cpu Time = 101.37 seconds
b : Real Time = 147.08 seconds Cpu Time = 140.51 seconds
Memory statistics:
Root size in memory (kb):
before running the macro 9440
after "writing" 15524
after "reading" 15524