LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET event callback memory leak

Hi

 

From my point of view this has been solved a long time ago but I am not 100% sure.

I think from LV2011+++ it was solved, but i did not make a test in the last few years.

Gernot Hanel
IONICON Analytik Gesellschaft m.b.H.
0 Kudos
Message 11 of 12
(349 Views)

Check your refnums!!! If you create a refnum and pass it to an object you still have to close it. That is because .NET uses refcounting for objects. Passing an object (refnum) to a method will increase its refcount and if you do not close the refnum, that object will remain in memory since the object itself will only release one refcount and the remaining refcount will keep it alive.

 

In the case of Neils example he did another potential but similar problem. Every time he initializes a timer he creates both a .NET Timer object and a user event refnum but he seems to have forgotten to post the diagram for the Destroy.vi method of his timer class where he closes both these refnums and makes sure he matches each Initialize.vi call with exactly one Destroy.vi call.

 

LabVIEW refnums use memory, and the underlaying .NET object too. Creating such objects without closing them dilligently will look like a memory leak but is simply proper operation. LabVIEW does exactly what you told it not to do!!

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 12 of 12
(345 Views)