"storage exhausted" issue [solved]

Hi,

I have to use a ROOT program that I’ve not written by myself, and which eats too much memory (more than 2 Go dixit the “top” command) so that it crashes looping on the message :

[quote]Fatal in : storage exhausted (failed to allocate 37 bytes)
aborting[/quote]
Since the program calls some custom classes that I’m not the creator, it is difficult to find out where this issue comes from. After reading the RootTalk messages about this kind of errors, I tried to search for some TTrees or TChains in the files but I found nothing.

So, is there any way to find which objects are growing up when the program is running, or something like this ? (The program does not run under ROOT console)

Thank you for any suggestion.

Hi,

use valgrind (valgrind.kde.org)

Axel.

Thanks, that’s a great idea, I didn’t know this program which will help me to solve other problems, I think. :wink:

But for this one, after a long, long, long time running the program under valgrind, I have the same errors and valgrind quits :

[quote]…
Fatal in : storage exhausted (failed to allocate 37 bytes)
aborting

Valgrind’s memory management: out of memory:
memcheck:allocate new SecMap’s request for 73728 bytes failed.
3106840576 bytes have already been allocated.
Valgrind cannot continue. Sorry.[/quote]
:cry:

Try running with less events, valgrind should still detect the memory leak.

Philippe

Ok, I finally found the problem, but I don’t know how to solve it… Here is a sample of the code :[code]
double systResolve(int npar,double *gX,double *gM,double **gP){

TMatrixD *X=new TMatrixD(npar,1);
TMatrixD *M=new TMatrixD(npar,npar);
TMatrixD *P=new TMatrixD(npar,1);

P->Mult(*M,*X);
*gP=P->GetMatrixArray();
delete X;
delete M;
// delete P; (if uncommented, bad results)
return det;
}

int fitnpe(int nbpe,float *chi2,float *amplitude,int *time,float *base){

double gX[npar],gP;
double gM[npar
npar];

det=systResolve(npar,gX,gM,&gP);

// delete gP; (if uncommented, crash)
}
[/code]
The “delete gP” line makes the program crash with an error about which I did not find lots of information :

[quote]Fatal in : unreasonable size (1018167296)
aborting[/quote]
How could I delete it, or force the program to use the same TMatrix at each turn ?

Thanks in advance for any help.

[quote=“berder”]So, is there any way to find which objects are growing up when the program is running, or something like this ? Thank you for any suggestion.[/quote]I think you should active the flag Root.ObjectStat: 0(see your $ROOTSYS/etc/system.rootrc file and add the gObjectTable->Print() statement somewhere in your code
See: root.cern.ch/root/htmldoc//TObje … escription

I am not sure I understand what you did mean. Do you see this as an obstacle?

[quote=“fine”]I am not sure I understand what you did mean. Do you see this as an obstacle?[/quote]I thought it should be easyer to see the ROOT objects “in live” under a ROOT console than with an external program, but maybe I’m wrong…

Thanks for the suggestions, but in fact I solved the problem like this :

[code]double systResolve(int npar,double *gX,double *gM,double *gPi){ // *gPi INSTEAD OF **gP
double *gP; // NEW

TMatrixD *X=new TMatrixD(npar,1);
TMatrixD *M=new TMatrixD(npar,npar);
TMatrixD *P=new TMatrixD(npar,1);

P->Mult(*M,*X);
gP=P->GetMatrixArray(); // gP INSTEAD OF gP
for(int i=0;i<npar
npar;i++) gPi[i]=gP[i]; // NEW
delete X;
delete M;
delete P; // UNCOMMENTED
return det;
}

int fitnpe(int nbpe,float *chi2,float *amplitude,int *time,float *base){

double gX[npar],gP;
double gM[npar
npar];
double gP2[npar][npar]; // NEW

det=systResolve(npar,gX,gM,&gP2[0][0]); // &gP2[0][0] INSTEAD OF&gP

(CALL OF gP2[0][n] INSTEAD OF gP[n])

// delete gP; (if uncommented, crash)
} [/code]
and it works fine.

Thanks for all ! :wink: