Hello I have a Server application that uses Matlab, this works fine when I
use the Execute method to evaluate and retrieve data. However, using the
method GetFullMatrix in the method getvar seems to cause a memory leak.
Anyone got any idea?
I use the following code for the communication with Matlab
import pythoncom, pywintypes
from win32com.client import Dispatch
class MatlabServer():
def __init__(self):
pythoncom.CoInitialize()
matlab_object = Dispatch('matlab.application.single')
self.execute = getattr(matlab_object, 'Execute')
self.putfullmatrix = getattr(matlab_object, 'PutFullMatrix')
self.getfullmatrix = getattr(matlab_object, 'GetFullMatrix')
self.getchararray = getattr(matlab_object, 'GetCharArray')
def __del__(self):
pythoncom.CoUninitialize()
def setvar(self, xnam, x, workspace = "base"):
if type(x) is not list:
x = [ x ]
self.putfullmatrix(xnam, workspace, x, None)
def getvar(self, xnam, workspace = "base"):
try:
return self.getfullmatrix(xnam, workspace, None, None)[0]
except pywintypes.com_error:
return []
def getstring(self, xnam, workspace = "base"):
try:
return self.getchararray(xnam, workspace)
except pywintypes.com_error:
return ''
/Thomas
_______________________________________________
python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32