sneumann / Rdisop

This is the git repository matching the Bioconductor package Rdisop: Decomposition of Isotopic Patterns
4 stars 7 forks source link

Possible memory leak in addMolecules/subMolecules #1

Open stanstrup opened 9 years ago

stanstrup commented 9 years ago

It looks like there is a memory leak in addMolecules/subMolecules. If you do:

elements=c(  initializePSE(),initializeCharges()   )

for (i in 1:8000){
     addMolecules("H38N32O15P8","H",elements=elements)$formula
}

Several hundred MB are consumed that are never released again (gc() doesn't help). Even if saving the output only takes 500 Kb.

sneumann commented 9 years ago

Hi, the high memory requirements are already present without the addMolecules() call:

echo 'library (Rdisop) ; elements=c(  initializePSE(),initializeCharges()) ; for (i in 1:100000){ getMolecule("H38N32O15P8",elements=elements)$formula } ' | R --vanilla

Not sure where to fix that.

jalic commented 8 years ago

Hi Stan, as Steffen already pointed out also get-functions are effected. My hypothesis is that in connection with C-code GarbageCollection doesn't work. Until it is fixed you can either substitute by your own function or use the equivalent functions from the enviPat package. But careful, enviPat requires explicit C1H4 instead of CH4, so you have to use enviPat::check_chemform before processing Rdisop output.