Opensim memory leak during for loop
Posted: Thu Dec 03, 2020 9:05 pm
Hi,
I'm trying to run a for loop over a OpenSim analyze tool in python. I have to run over 100000 kinematic instances with the analyzing tool, but after 1000 instances the memory will be filled and my script is crashed. Is there any way we to resolve the issue? I tried to del the create osim.AnlayzeTool after each instance but it did not work!
The memory keep increasing linearly after each iteration.
[/code]
def run_analyze(self, ik_file, analyze_result_folder):
self.analyzeTool = osim.AnalyzeTool(self.analyze_setup_file)
motCoordsData = osim.Storage(ik_file)
initial_time = motCoordsData.getFirstTime()
final_time = motCoordsData.getLastTime()
start = [i for i, c in enumerate(ik_file) if c=='/'][-1]+1
name = ik_file[start:][:-4]
self.analyzeTool.setName(name)
self.analyzeTool.setModelFilename(self.model)
self.analyzeTool.setResultsDir(analyze_result_folder)
self.analyzeTool.setCoordinatesFileName(ik_file)
self.analyzeTool.setInitialTime(initial_time)
self.analyzeTool.setFinalTime(final_time)
self.analyzeTool.setLowpassCutoffFrequency(6)
analysis_set = self.analyzeTool.getAnalysisSet()
nAnalysis = analysis_set.getSize()
for k in range(nAnalysis - 1):
analysis = analysis_set.get(k)
analysis.setStartTime(initial_time)
analysis.setEndTime(final_time)
self.analyzeTool.run()
del self.analyzeTool
For i in range(100000):
...
...
do run_analyze()
I'm trying to run a for loop over a OpenSim analyze tool in python. I have to run over 100000 kinematic instances with the analyzing tool, but after 1000 instances the memory will be filled and my script is crashed. Is there any way we to resolve the issue? I tried to del the create osim.AnlayzeTool after each instance but it did not work!
The memory keep increasing linearly after each iteration.
[/code]
def run_analyze(self, ik_file, analyze_result_folder):
self.analyzeTool = osim.AnalyzeTool(self.analyze_setup_file)
motCoordsData = osim.Storage(ik_file)
initial_time = motCoordsData.getFirstTime()
final_time = motCoordsData.getLastTime()
start = [i for i, c in enumerate(ik_file) if c=='/'][-1]+1
name = ik_file[start:][:-4]
self.analyzeTool.setName(name)
self.analyzeTool.setModelFilename(self.model)
self.analyzeTool.setResultsDir(analyze_result_folder)
self.analyzeTool.setCoordinatesFileName(ik_file)
self.analyzeTool.setInitialTime(initial_time)
self.analyzeTool.setFinalTime(final_time)
self.analyzeTool.setLowpassCutoffFrequency(6)
analysis_set = self.analyzeTool.getAnalysisSet()
nAnalysis = analysis_set.getSize()
for k in range(nAnalysis - 1):
analysis = analysis_set.get(k)
analysis.setStartTime(initial_time)
analysis.setEndTime(final_time)
self.analyzeTool.run()
del self.analyzeTool
For i in range(100000):
...
...
do run_analyze()
Code: Select all
Thanks for your help in advance.
Mohsen