10-06-2009 10:52 AM - edited 10-06-2009 10:55 AM
Hey Hans,
There is a possible solution to this problem....but needs to be handled in the DLL (.Net Code).
Since GC of .Net is able to find the root as active due to some reason (NI's LabVIEW might also be a culprit), so the only way seems like doing a manual free operation in conjunction with your LabVIEW Code.
In your EventCallback.VI file, whenever you are done with your event handling, call a method say FreeMemory() which will be defined in your C# code. You might pass the memory reference to the DLL which in turn will free that memory (you have to write this code). This way you might avoid a memory leak.
I have attached a rudimentary snapshot. Hope you got the idea ?
--Tirthankar
10-12-2009 03:49 AM
Hi Tirthankar,
your idea of passing the references back to the DLL may seem not bad. Alas, with a possible FreeMemory() method you can do little more than telling the Garbage Collector, "Do
the cleanup now!" instead of waiting until it's done automatically. You
don't really do a "manual" memory release either way in managed
code and when LabVIEW still holds a reference to the objects, I doubt the GC
will release them.
Anyway, I'll give it a try and tell you about the results.
Cheers,
Hans
10-22-2009 03:00 AM
@Imagineer wrote:
In your EventCallback.VI file, whenever you are done with your event handling, call a method say FreeMemory() which will be defined in your C# code. You might pass the memory reference to the DLL which in turn will free that memory (you have to write this code). This way you might avoid a memory leak.
Just to give you an update: I've tried the GC.Collect() method to force a garbage collection, nevertheless the memory still increases over time. Just as I'd expected...
Yet there's some better news: With the original LabVIEW 2009 release, the bug is still there. But when you apply the latest patch, it's history!
See http://digital.ni.com/public.nsf/websearch/C3F88F3596A164AD86257647006FB022?OpenDocument
Although we've to stick to LV 8.x at the moment, it's good to see that my problem analysis was correct and the bug didn't turn out to be a simple coding mistake or so. Moreover, the "stepchield" .NET within LabVIEW finally got some attention and there's a little hope growing that NI will maintain this (in my opinion) most important area somewhat better in the future.
Cheers,
Hans
10-22-2009 03:47 AM
Hans,
thanks for the update to the community. Esp. the pointer to the f2-patch for 2009 is valuable. I am glad that this patch resolves the issue.
Norbert