LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET Memory leak

Hello everyone,
I am experiencing memory .NET reference leak. I have an third party hardware with C# dlls. It is simple measuring hardware with simple test VI: ( Init-> Config -> Start stream -> getting data in a loop -> stop stream -> close). Thing is that after a while my VI ends up with classic error 2: Out of memory. I am aware that C# references should be closed. I have used the DETT tool for detecting where the leak is located. DETT detects the .NET reference leaks. Unfortunately I am not able to locate the source of the error. Please could some1 have a look where the error could be located? I would be glad for any hint how to resolve or debug more precisely. The memory "overflows" in couple of hours, so obviously I suspect  the data stored in some .NET object, but this particular reference is closed everytime it is fetched.
BTW: using LV 2016 (x64)
Memory_issues.png
image.png



0 Kudos
Message 1 of 6
(3,353 Views)

the snippet you posted, is just a very pixelated regular  .png

that's an issue with this forum.

upload the .vi - if we should have a look.

 

how well can you reproduce the error?

does it allows happen "after a couple of hours"?

 

does the error occur in the while loop or outside the while loop?

Therefore, spawn some extra error clusters,

and reproduce the error.

 

Could it be some hardware related issue?

 

 

 

 

 

 

 

 

Message 2 of 6
(3,334 Views)

Hello,

Hope this simple .vi upload will help.

Error will happen at GetChannelData() .Net node in the while loop, but it will not popup, only if you place an simple error handler after the command. Otherwise the VI will run without any interuption for couple of hours and then it freeze.

I have a feeling that Closing .Net data objects references is not working is it possible? Is there something that needs to be implement inside of DLLs, some dispose function or whatever? Or for example if the data objects are childrens of some another object which I am not using in LV, could it be also the issue?

Anyway hardware is working just fine, the problem is somewhere with LV+.NET. If I create this simple app in C# directly, the memory will not grow.

Thank you for any advice.

 

0 Kudos
Message 3 of 6
(3,311 Views)

Note that nothing is stopping those .net methods from allocating .net references and not closing them!

 

In other words, the .net code might be leaking, not you.

0 Kudos
Message 4 of 6
(3,302 Views)

If it is this case.

Is it possible to somehow repair this issue (garbage collector or something)? Or maybe to debug somehow to see which objects are responsible for "violant" allocation? 

0 Kudos
Message 5 of 6
(3,296 Views)

I think debugging .net assemblies while inside LabVIEW isn't that easy.

 

Has this driver been used before? Do 'they' provide a c# example that doesn't leak? It's not that hard to make a c# program that does the same you're doing in LabVIEW...

 

I'd say your program is pretty solid. If it leaks, I'd contact the makers first.

0 Kudos
Message 6 of 6
(3,286 Views)