Hi ptolemy hackers, In our situation we have embedded part of the Ptolemy kernel in our application, parsing models using an instantiated MoMLParser and executing models using a ModelManager. We have been doing this for some time for many constructed models, without any problems. Last week I constructed a SDF model which includes a StringCompare actor. When repeatedly executing the model, reusing the objectgraph constructed during model parsing, I ran into some memory problems.
We started profiling our application and found out that memory use increases during every new model execution. However this is only the case when executing the SDF model that includes the StringCompare actor. Pin-pointing the problem further We found out that the PortParameters of the StringCompare actor (first/second string) are stored as rate variables (linkedlist) in the SDFScheduler. After every execution of the model graph, the size of the rate variables list increases by new added PortParameters. Note that before each model execution the model manager is properly initialized and the initialize()/preinitialize() methods of actors are invoked. Because the model is initialized before execution I would expect that the rate variables list of the SDFScheduler is cleared during initialization (or during the wrapup of the last execution). However this is not the case. Scanning the sourcecode of the SDFScheduler and base classes I found no trace of code that properly clears the rate variables list. In order to make sure that our problem is caused by the memory use of the SDFScheduler we subclassed the SDFScheduler and overrrided the preinitialize() method by this code: public void preinitialize() throws IllegalActionException { try { getScheduler().setContainer(null); new SDFScheduler(this, uniqueName("Scheduler")); } catch (NameDuplicationException e) { throw new IllegalActionException(e.getMessage()); } super.preinitialize(); } This code removes the current scheduler from the model container and instantiates a new SDFScheduler with a clean rate variables list. This patch solves our memory problem. I don't know if the SDFDirector and SDFScheduler has been designed with object reuse in mind, many actor classes do because they include proper initialize and wrapup code. Kind regards, Richard van der Laan, luminis TheWeb: http://www.luminis.nl ---------------------------------------------------------------------------- Posted to the ptolemy-hackers mailing list. Please send administrative mail for this list to: [EMAIL PROTECTED]