Skip to main content
13-Aquamarine
July 7, 2020
Question

How can the Web.Link caller do the ProArrayFree() for memory allocated by ProTkdllFunction callee

  • July 7, 2020
  • 2 replies
  • 1811 views

ProArray allocated in the ProTkdllFunction like this:

    status = ProArrayAlloc(1, sizeof(ProArgument), 1, (ProArray*)outputs);

for the function's output arguments. These output arguments need to be free'ed once after being used. 

The question is: How can the Web.Link caller do the ProArrayFree() or ProArgumentProarrayFree()? 

2 replies

17-Peridot
July 7, 2020

If I understand your question correctly....

 

You should be able to just use normal javascript operations - like re-initialize it to an empty array.

 

// init with values

var myArr = [1,2,3,4,5];

 

// to clear it...

var myArr = [];

 

Dave

Kittychen13-AquamarineAuthor
13-Aquamarine
July 8, 2020

That memory is allocated in ToolKit C language code and return the reference to JavaScript as an output object. I think to redirect the object token to an empty array would not release that allocated memory. But I don't know how to call the official ToolKit C language function, ProArrayFree(), from Web.Link JavaScript side, not even know anything about the input arguments it needs.

 

If the suggestion is actually on the correct direction, we probably can try to 'delete' that returned object? Delete it and its destructor  magically do the right things to call ToolKit to release the memory? 

17-Peridot
September 29, 2020

Looks like no needed to free the array.

I saved pointer to the array in to global variable and was try to free it at user_terminate() function. But memory was changed before and I got PRO_TK_BAD_INPUTS.