07-31-2013 08:51 PM
I'm using the call library function node (CLFN) to load a few DLLs dynamically in a same vi.
I use a for loop to send an array or DLL paths to CLFN to load different DLLs.
For the first iteration, the CLFN is working fine but for the second and so on iteration cannot overwrite the output variable and keep on repeating the first iteration's result.
Is there anyway to flush the CLFN memory so that i will get the correct result for 2nd DLL and so on?
Solved! Go to Solution.
07-31-2013 10:39 PM
I don't know if this will work, but try alternating the valid paths with empty paths in the array. An empty path should force the call library function node to unload the DLL, which might then allow it to load the new one on the following iteration.
07-31-2013 10:49 PM
Here's knowledge base article about that
http://digital.ni.com/public.nsf/allkb/77594203D78D12278625729100758BE5
08-01-2013 04:52 AM
Yes. I tried to load a "not a path constant" to the CLFN path node to unload the DLL and flush the memory.
But it was still the same.
However to be accurate, the output result from DLL is not actually exactly the same as the first DLL output, it is just replaced.
For example, DLL 1 outputs 33 data and DLL 2 outputs 3 data.
After DLL 1 & 2 called, the output array size will still be 33 instead of 3, but the first 3 index item are from DLL 2, and the 4th, 5th and so on are from DLL 1.
So what i do now is just extracting the first few index items i want.
Still, i was wondering if there is a way to flush the CLFN output memory.....
Any LabVIEW expert can help?
08-01-2013 06:10 AM
As far as i understand your post, you have different DLLs which all return an array to LabVIEW.
This array can be different size depending on the DLL you are calling.
I think you run into a general misunderstand regarding LV memory management. I think that your remarks refer to the dataspace LV has allocated for the array, this has nothing to do with the DLL itself!
LV works conservative regarding memory. So if you did allocate a dataspace, a new execution of the same VI will try to re-use all of that dataspace. Therefore, arrays are not freed if the VI is going idle.
That being said, the array itself will not reduce its size.
The only question i have on this: Do you have still all values available? If the new call returns three values (out of 33), are the rest 30 elements "the old value"?
For ANSI C-DLLs it is common that the DLL also returns a scalar value "arraysize". If you got that, you can use the Array Subset function to extract the valid values.
Norbert
08-04-2013 07:54 PM
Thanks Norbert, that is exactly what i'm doing in my software now. By using the array subset function.
11-11-2013 10:21 PM
I have the same problem as the array memory management, I use an input array and an output array to a dll,the size of input array is variable, and the size of output array is the size of input array +2. when i run this, it is good ,and give correct answer. but when i add a while loop , and the input array and the output array,and the call library function node are all in the while loop, error ocuurs.: memory is full or LabVIEW stoped. i think it is a problem of how to free array memory, please tell me how to free an array memory.
11-12-2013 01:52 AM
Hi JianChen,
When you are setting array for input or output of the call library function node, you need to add another input as the size of the array too. Normally it is auto generated by labview and named as "len", "len1", "len2" and so on.
11-12-2013 10:43 AM
What's going on inside the DLL function? Do you have code for it? Are you sure you want to pass data to it as an Array Handle?