Memory allocation errors?

Greetings all. My code uses a compiled function that accepts some input parameters and runs a quick simulation I’ve written. I have a root CInt script that I use to loop over the parameter space I’m interested in. The error messages look like:

root.exe(1050) malloc: *** mmap(size=16777216) failed (error code=12)
*** error: can’t allocate region

Then I get a lot of output that I think comes from gdb. Is this a memory leak problem on my part, or something else entirely? I’m running on a Macbook Pro with Root v.5.20/00.

Cheers,

Vic

Could you post the shortest possible RUNNING script reproducing this problem?
Are you running the executable root.exe or your own executable?
If it is your own executable, are you linking with -lNew? if yes remove this library from your link sequence.

Rene

[quote=“brun”]Could you post the shortest possible RUNNING script reproducing this problem?
Are you running the executable root.exe or your own executable?
If it is your own executable, are you linking with -lNew? if yes remove this library from your link sequence.

Rene[/quote]

I’ve attached the code. I run this by just passing RunCalculation.C to root.exe at the command line (i.e. “root RunCalculation.C”).
RunCalculation.C (2.93 KB)
DarkMatterSpectrum.h (16.2 KB)
DarkMatterSpectrum.C (8.66 KB)

Hi,

You simply run out of memory.

Several of the functions in the code your provided are leaking objects.
For example QuenchEnergy_LindhardIonization allocates 5 TString and never delete them (kFormul, eFormula, gFormula, QuenchingFunctionFormula and the result of all the call to Copy!). Use TString kFormula("0.133 * TMath::Power([0], 0.66667) * TMath::Power([1], -0.5)"); TString eFormula("16.2585 * x * TMath::Power([0], -2.3333)"); TString *gFormula("(3. * TMath::Power("); gFormula.Append(eFormula); gFormula.Append(", 0.15)) + (0.7 * TMath::Power("); gFormula.Append(eFormula); gFormula.Append(", 0.6)) + ("); gFormula.Append(eFormula); gFormula.Append(")"); // Construct the quenching formula from g, k and epsilon... TString *QuenchingFunctionFormula("("); etc...
[Note that this ‘pattern’ is repeated in all the places you do string manipulation]

In addition, QuenchEnergy_LindhardIonization creates a new TF1 object each time it is called and those object do not appear to ever be deleted.

Cheers,
Philippe.