Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Passing arrays to MathLink without extra memory allocation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98736] Passing arrays to MathLink without extra memory allocation
  • From: axnavaei at googlemail.com
  • Date: Fri, 17 Apr 2009 04:29:04 -0400 (EDT)

Hi,

When passing a list/array from mathematica to c using mathlink, eg
when calling MLReleaseInteger32List(), it seems mathlink allocates
some memory which later has to be freed, eg using
MLReleaseInteger32List(). The question is, how is it possible to pass
a list from mathematica to c without this c memory allocation?

This example helps to make the question more clear: Assume MyFunction
[BigList] to be a function implemented in c using mathlink, where
BigList is a list of integers. Since BigList has been already created
in mathematica and its corresponding memory has been allocated, we do
not wish to allocate memory once again in c. It looks like one option
is to pass BigList by reference, that is:

SetProperties[MyFunction, HoldAll]

In this case, does mathlink still allocate memory and copy BigList in
the c side?


  • Prev by Date: Re: FindRoot
  • Next by Date: Re: tooltip - evaluate function at point
  • Previous by thread: Re: getting data points instead of a plot in ListContourPlot ?
  • Next by thread: Re: Passing arrays to MathLink without extra memory allocation