LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Flushing the memory from the call library function node

Solved!
Go to solution

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? 

0 Kudos
Message 1 of 9
(3,968 Views)

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.

0 Kudos
Message 2 of 9
(3,947 Views)
0 Kudos
Message 3 of 9
(3,944 Views)

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?

0 Kudos
Message 4 of 9
(3,927 Views)
Solution
Accepted by topic author brock85

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

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 5 of 9
(3,922 Views)

Thanks Norbert, that is exactly what i'm doing in my software now. By using the array subset function.

0 Kudos
Message 6 of 9
(3,902 Views)

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.

0 Kudos
Message 7 of 9
(3,789 Views)

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.   

0 Kudos
Message 8 of 9
(3,782 Views)

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?

0 Kudos
Message 9 of 9
(3,760 Views)