Search code examples
wolfram-mathematicamathlink

Mathlink memory usage accumulation


I use MathLink to send and receive independent mma expressions from a C++ application as strings.

std::string expression[N];
// ...
for(int i = 0; i < N; ++i) {
    MLPutFunction(l, "EnterTextPacket", 1);
    MLPutString(l, expression[i].c_str());
    MLEndPacket(l);

    // Check Packet ...

    const char* result;
    MLGetString(l, &result);

    // process result ...

    MLDisownString(l, result);
}

I would expect that MLDisownString frees the used memory except that it doesn't.

Any ideas?


Solution

  • Ok. Posting this as an answer, because I believe the odds you are using version 5 or below are pretty low:

    `As of Version 6.0, MLDisownString() has been superseded by MLReleaseString()`
    

    Check it here