Dear all I wanted to figure out what's the best way to estimate the amount of shared memory needed beforehand (I am using the root TMapFile class) Just try and make it big enough just doesn't sound right. I would like to limit the space used and i would like to avoid segmentation violation when i run out of space. (Would be nice to get a warning instead of a seg violation.) What is the best way to calculate the amount of space needed. Below i have included a little script which prints the information and jumps out of the loop when the memory is full. Any suggestions. What i found irritating is the fact that you have to give the TMapFile a minimum amount of space or you will end up with a segmentation violation the first time you update it. thanks in advance cheers hans mfile = TMapFile::Create("hsimple.map","RECREATE", 40000,"Demo memory mapped file with histograms"); for (Int_t ipmt=0;ipmt<10000;ipmt++) { char name[25]; char title[25]; sprintf(name ,"Atom%d",ipmt); sprintf(title,"Atom%d",ipmt); Atom *junk = new Atom(name,title,ipmt*2,ipmt); mfile->Add(junk); usedspace = mfile->GetBreakval() - mfile->GetBaseAddr(); whatisleft = mfile->GetSize() - usedspace; // mfile->ls(); cout << "current break value: "<< mfile->GetBreakval() << " used space: " << usedspace << " space left: " << whatisleft <<endl; if (whatisleft<0) { cout << "shared memory is full" << endl; break; } mfile->Update(); } cout << " jumped out of the loop" << endl; mfile2 = TMapFile::Create("hsimple2.map","RECREATE", 50000,"Demo memory mapped file with histograms"); for (Int_t ipmt=0;ipmt<10000;ipmt++) { char hname[25]; char htitle[25]; sprintf(hname ,"histo%d",ipmt); sprintf(htitle,"histo%d",ipmt); TH1F *hadc = new TH1F(hname,htitle,200,0,100); mfile2->Add(hadc); usedspace = mfile2->GetBreakval() - mfile2->GetBaseAddr(); whatisleft = mfile2->GetSize() - usedspace; cout << "current break value: "<< mfile2->GetBreakval() << " used space: " << usedspace << " space left: " << whatisleft <<endl; if (whatisleft<0) { cout << "shared memory is full" << endl; break; } mfile2->Update(); } cout << " jumped out of the loop2" << endl; } wenzel/atom> root ******************************************* * * * W E L C O M E to R O O T * * * * Version 2.22/06 23 June 1999 * * * * You are welcome to visit our Web site * * http://root.cern.ch * * * ******************************************* CINT/ROOT C/C++ Interpreter version 5.14.6, Jun 10 1999 Type ? for help. Commands must be C++ statements. Enclose multiple statements between { }. root [0] .x atom_size.C Warning: Automatic variable usedspace allocated in global scope FILE:/home/wenzel/atom/./atom_size.C LINE:15 Warning: Automatic variable whatisleft allocated in global scope FILE:/home/wenzel/atom/./atom_size.C LINE:16 current break value: 0x40c97000 used space: 32768 space left: 7232 current break value: 0x40c99000 used space: 40960 space left: -960 shared memory is full jumped out of the loop current break value: 0x40ca1000 used space: 32768 space left: 17232 current break value: 0x40ca4000 used space: 45056 space left: 4944 current break value: 0x40ca4000 used space: 45056 space left: 4944 current break value: 0x40ca5000 used space: 49152 space left: 848 current break value: 0x40ca5000 used space: 49152 space left: 848 current break value: 0x40ca6000 used space: 53248 space left: -3248 shared memory is full jumped out of the loop2 -- ________________________________________________________________________________ Hans Wenzel | Phone: (630) 840 8240 Inst. für Experimentelle Kernphysik | (630) 393 1756 University of Karlsruhe (germany) | Fax: (630) 840 2968 .~. L Fermilab MS 318 | email: wenzel@fnal.gov /V\ I P.O.Box 500 | http://kcdf1.fnal.gov/~wenzel/ // \\ N Batavia 60510,Il | /( )\ U ______________________________________________________________________ ^`~'^__X_
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:38 MET