MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Question regarding MathLink memory use

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127783] Question regarding MathLink memory use
  • From: samid.hoda at gmail.com
  • Date: Wed, 22 Aug 2012 02:26:40 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net

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



  • Prev by Date: Re: Constraining a Location to Move Along a Plot in a
  • Next by Date: Problems with dynamic tables
  • Previous by thread: Washington DC Area Mathematica SIG
  • Next by thread: Problems with dynamic tables