Hi,
I have a memory leak issue when using DSNewHClr, DSDisposeHandle in C function inside a dll called using call library node.
I pass to the function an empty array of my top-level cluster (that has nested arrays of clusters, strings and numbers). I remove the existing handles (using DSDisposeHandle) and create new ones with the size I need (also set the array dimSize accordingly). I also create new handles for the nested arrays. So I'm not resizing any array to reduce its size or number of items. I create new handles with the required size and set the number of members. The output cluster looks fine and contains all the data I expect, and all array sizes are fine as I set on my C function. But this leads to a memory leak.
I don't know how many items arrays should have until I'm inside the C function. I have seen that you recommend in those cases to make two calls to the C functions. One for getting the number of required items, then resize arrays in LabVIEW and pass the resized arrays another C function with the required size. Due to performance reasons, I would prefer to do everything on a single call.
I think that the memory allocated by my calls to DSNewHClr is not freed. Does LabVIEW take ownership of the handles I created? Should LabVIEW release that memory or should I store the pointers to the handlers and release later? (I tried and crash). Is it DSNewHClr for my use case?
P.D For simple numeric types I use NumericArrayResize(). But I need DSNewHClr for arrays of clusters.
Regards