LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

References in Memory

What happens to reference in an array?  Let's say I create an array of rerences using a For Loop, but I don't close said references.  Then, I recreate that same array with new references.  Will the originaly be destroyed or will it still be in memory?  Will the failure to close these references be an issue?  What if it is references that point to items within a DLL?

0 Kudos
Message 1 of 7
(3,261 Views)

Depends if the ref is staic or dynamic.

 

Rolf K taought us years ago to cast a reference as I32 and run the VI. let it stop and run it again. if the number changes, it is dymanic. If it stays the same then static.

 

Dynamics will carry a small memory allocation with them. If you get them too often it will leak memory.

 

can't speak specifically to the dll twist.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 7
(3,253 Views)

Yeah, I've got a memory leak and I'm using a DLL.  The DLL is producing the references, but I don't see them being closed.  I just see the array being re-created and ovewriting the data in a cluster.

0 Kudos
Message 3 of 7
(3,245 Views)

@Ben wrote:

 

Rolf K taought us years ago to cast a reference as I32 and run the VI. let it stop and run it again. if the number changes, it is dymanic. If it stays the same then static.


Yeah I like that idea, another I've tried is to run the VI with a run continuously.  Normally I tell others to never use this feature, but it is handy for testing memory leaks.  Write the VI that opens and closes references the way you think shouldn't cause any leaks, then run continuously and look at the memory in task manager.  If it goes up you aren't closing everything you should.

0 Kudos
Message 4 of 7
(3,168 Views)

@Hooovahh wrote:

@Ben wrote:

 

Rolf K taought us years ago to cast a reference as I32 and run the VI. let it stop and run it again. if the number changes, it is dymanic. If it stays the same then static.


Yeah I like that idea, another I've tried is to run the VI with a run continuously.  Normally I tell others to never use this feature, but it is handy for testing memory leaks.  Write the VI that opens and closes references the way you think shouldn't cause any leaks, then run continuously and look at the memory in task manager.  If it goes up you aren't closing everything you should.


Closing is not always enough. Opne a VISA ref then close it repetedly and run it non-stop over the week-end. Dynamic refs get a resource allocated that is not cleared until the VI goes idle. Rolf's technique will predict which refs will appear to "leak".

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 7
(3,146 Views)

@Ben wrote:

Dynamic refs get a resource allocated that is not cleared until the VI goes idle. 


Good thing with run continuous the VI goes idle between executions (or I assume Smiley Frustrated).

0 Kudos
Message 6 of 7
(3,129 Views)

@DailyDose wrote:

Yeah, I've got a memory leak and I'm using a DLL.  The DLL is producing the references, but I don't see them being closed.  I just see the array being re-created and ovewriting the data in a cluster.


Can you be more specific than "reference" here? In LabVIEW, a reference could be a DVR, or a reference to a front-panel item, or a queue/notifier/etc reference number (refnum). None of these make sense in the context of a DLL, though. Are you saying the DLL allocates memory and returns a pointer?

 

If you can show your code, and some documentation on the DLL, then we might be able to provide a more useful answer. The solution might be as simple as using a shift register to force LabVIEW to pass the same cluster to the DLL each time, but we need more information.

0 Kudos
Message 7 of 7
(3,110 Views)