LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

free array memory

Solved!
Go to solution

Hello, I'm working on a project that i m going to build into a DLL and use it later on a CVI Program. 
In my labview VI I'm using a massive array of uint8 (sized, 10000000 byte) saved into memory and i m calling it via its reference, and it works fine in labview and in my CVI test program.

I have two questions : 

1) when i m done using the dll in my C sequence (I mean the program is testing the products in a loop and each time it calls the functions of the dll), does the memory allocated for the array, free up automatically, or do I need to manually clear it ? 

If so, how can I do that using only the reference.(in LabVIEW or in CVI) ?

The array saves an image.

 

0 Kudos
Message 1 of 3
(924 Views)
Solution
Accepted by hmdfr97

Hi hmdfr,

 


@hmdfr97 wrote:
In my labview VI I'm using a massive array of uint8 (sized, 10000000 byte) saved into memory and i m calling it via its reference

1) when i m done using the dll in my C sequence (I mean the program is testing the products in a loop and each time it calls the functions of the dll), does the memory allocated for the array, free up automatically, or do I need to manually clear it ? 

2) If so, how can I do that using only the reference.(in LabVIEW or in CVI) ?


  • Do you use a frontpanel element to hold this array and then the reference of that frontpanel element to access its data? (I guess there would be better options…)
  • 10MB isn't "massive" in my opinion, it only becomes a problem when you create a lot of those arrays.
  • How do you "save the array into memory"?
  • Why do you allocate the memory in your VI/DLL function? Why not let the caller alloc/free the memory?

Set the value of that array to "empty array" to free the momory…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 3
(919 Views)

Thank you for your reply.

Yes, I used a fontanel element to hold it, then I created a reference to that element and built the dll.

 

In my application, I was declaring the entire array each time I access the module containing the dll (a turntable of a tester with a labwindows sequence) I have no idea if it is cleared or not but the application crashes often, so I decided to use a reference instead and start looking (i m just getting started with labview by the way). I run a test now to see if the memory increases and I found out after I pass by the station containing the sequence, the memory adds up a bit. 

But now setting the array to a default value using an invoke node worked just fine.

 

This all is because I'm using an IMAQ image and I want to pass it between functions without using a global variable or the data itself. When I build a dll it gives me an uintptr_t that I can't use, so I converted it to an array but if there is any other solution I am all ears.

 

Thanks again @GerdW

0 Kudos
Message 3 of 3
(878 Views)