Skip to content

O.reset() does not free memory

O.reset() does not free the memory, i.e. if you run a series of simulations in a loop the memory usage is accumulating. Here is a script which reproduces the issue (it should affect all versions):

# -*- coding: utf-8
import subprocess

numberTests = 10

for z in range(numberTests):

 O.reset()

 O.bodies.append(pack.regularHexa(pack.inSphere((Vector3(0.0,0.0,0.0)),0.5),radius=0.01,gap=0))
 print "number of bodies:", len(O.bodies)

 cmd = "ps -o vsz -p `pgrep yade` | grep -v VSZ"
 process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
 meminfo = process.communicate()[0].strip()
 print "Yade memory usage: ", meminfo, "kB"

 cmd = "egrep 'MemFree' /proc/meminfo"
 process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
 meminfo = process.communicate()[0]
 print meminfo

sys.exit(0)

Original bug report by Klaus Thoeni on 2014-03-10 : https://bugs.launchpad.net/yade/+bug/1290194

Edited by Janek Kozicki