UI Windows form garbage collection problem with ActiViz

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

UI Windows form garbage collection problem with ActiViz

stevo
This post has NOT been accepted by the mailing list yet.
I have a code that takes in a 3D "radiation dose" grid, manipulates the grid in some way, then I get statistics of the manipulated grid with vtkImageAccumulate.  This process is iterated with different manipulation of the grid for each iteration.  

Actually the code works really works beautifully in console application in C#.  However, I notice that when I try to run the code in Windows Form Application (WFA), so that I can get my code running with a pushbutton, garbage collection does not occur!  Memory just keeps growing until the program crashes.  

Moreover, even when I run the code in WFA, the code runs just fine when I make the code run before the Windows Form with pushbutton appears, i.e. right after InitializeComponent() method.  

Somehow, the presence of Windows form on the screen prevents C# from automatic periodic garbage collection.  Would anyone know the cause, maybe even solution to this problem?  

Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: UI Windows form garbage collection problem with ActiViz

stevo
This post has NOT been accepted by the mailing list yet.
I resolved the issue by running the VTK calculation in BackgroundWorker.  Not only does this method leave the UI responsive, but it also clears memory more actively than when I run the VTK calculation in the main thread.