01-05-2007 10:09 AM
01-05-2007 12:27 PM
01-09-2007 06:57 PM - edited 01-09-2007 06:57 PM
Hi Jeramy,
LabVIEW uses "Memory Manager" to alloacte and free memory. Since LabVIEW allocated the array (inside the LabVIEW dll), it is up to the LabVIEW memory manger to deallaocte or free the memory. This might not occur until the dll is unloaded.
To handle the memory management in your C code, you may have to use the LabVIEW manager functions to allocate, free, and resize arrays, strings or other data structures that are passed into or out of your library from LabVIEW.
These functions are declared in the "extcode.h". The extcode.h is the header file for the set of LabVIEW manager functions that performs simple and complex operations including managing memory. To use the extcode.h you must include the "labview.lib" in your project. It is located in "c:\Programs file\labview7.1\cintools" directory.
A relevant function that will be applicable in this case (to free the memory) is the "AZDisposeHandle or DSDisposeHandle". For more information on this function and other memory management functions, checkout the " Using External Code in LabVIEW" reference manual, chapter 6 (Function Description), Memory Management Functions.
Tunde
Message Edited by Tunde A on 01-09-2007 06:58 PM
01-10-2007 03:42 PM - edited 01-10-2007 03:42 PM
@Tunde A wrote:
A relevant function that will be applicable in this case (to free the memory) is the "AZDisposeHandle or DSDisposeHandle". For more information on this function and other memory management functions, checkout the " Using External Code in LabVIEW" reference manual, chapter 6 (Function Description), Memory Management Functions.
Tunde
One specific extra info. All variable sized LabVIEW data that can be accessed by the diagram or are passed as native DLL function parameters use always DS handles, except the paths which are stored as AZ handles (But for paths you should use the specific FDisposePath function instead).
So in your case you would call DSDisposeHandle on the handle returned by the DLL. But if the array itself is of variable sized contents (strings, arrays, paths) you will have to first go through the entire array and dispose its internal handles before disposing the main array too.
Rolf Kalbermatter
Message Edited by rolfk on 01-10-2007 10:43 PM
01-10-2007 03:57 PM