﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
3764	OMCSession.sendExpression uses up all available memory when pyplot is imported	christopher.schoelzel@…	Martin Sjölund	"I wanted to create a testing script for my modelica models using OMPython when I discovered something very strange: The code example below behaves different depending on whether the pyplot module is imported or not. If the module is imported, the parser call in OMCSession.sendExpression will use up all available memory (at least up to 8 GB). If the module is not imported or if OMCSession.execute is used instead of OMCSession.sendExpression, the memory consumption stays below 100 MB.


{{{
#!python
# OS: Windows 7
# OMPython version: 2.0.7
# OpenModelica version: 1.9.4
# python version: 2.7.11
# output of 'pip freeze':
#   cycler==0.10.0
#   matplotlib==1.5.1
#   numpy==1.10.4
#   OMPython==2.0.7
#   pyparsing==2.1.0
#   python-dateutil==2.5.0
#   pytz==2015.7
#   six==1.10.0

import OMPython
# comment out the following line and the code below will work for both 'execute' and 'sendExpression'
import matplotlib.pyplot as plt

s = OMPython.OMCSession()
print s.sendExpression(""loadModel(Modelica)"")
print s.sendExpression(""simulate(Modelica.Electrical.Machines.Examples.DCMachines.DCPM_Start,stopTime=100,numberOfIntervals=100000)"")
# execute: normal behavior
data = s.execute(""readSimulationResult(currentSimulationResult,{time, ground.p.v, ground.p.i})"")
# sendExpression: consumes all available RAM
# data = s.sendExpression(""readSimulationResult(currentSimulationResult,{time, ground.p.v, ground.p.i})"")
del s
}}}"	defect	assigned	normal	Future	OMPython	v1.9.4-v1.9.x			
