cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

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

Kittychen
12-Amethyst

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

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()? 

3 REPLIES 3

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

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? 

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.

Top Tags