Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Question regarding MathLink memory use
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
samid.hoda@gmail.com

Posts: 4
Registered: 7/4/12
Question regarding MathLink memory use
Posted: Aug 22, 2012 2:25 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi,

I have a question about memory usage when using MathLink and C++. Here is my setup:

(1) A dynamic user interface in Mathematica which displays positions of points (the points are stored in a list).
(2) A C++ function that updates the position of the points.
(3) The dynamic user interface calls the C++ function with a list of current point positions and the C++ function returns a list of updated positions.

The C++ function has no memory leaks (the process size remains constant throughout the simulation); however, the Mathematica process (Windows 7) memory usage keeps growing as the simulation runs. Here is the code which returns the C++ computation to Mathematica via MathLink.

if (MLPutFunction(stdlink,"List" ,3)) {
if (!MLPutReal64Array(stdlink, pointTotalForces, dims, NULL, 2)) { /* Handle error ...*/ }
else if (!MLPutReal64(stdlink, Sim.meanPointForceMagnitude)) { /* Handle error ...*/ }
else if (!MLPutReal64(stdlink, Sim.maxPointForceMagnitude )){ /* Handle error ...*/ }
} else { /* Handle error ... */ }

The result is stored in a List in Mathematica, i.e., result = Simulate[....]. The points' positions then dynamically updated in a visualization. I am using Mathematica version 8.0.4 in Windows 7 and the MathLink code is a 64-bit executable built with Visual Studio 2010.

I would appreciate any suggestions.

Sam




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.