Sameer Adhwaryu

Sameer Adhwaryu

  • 1.5k
  • 105
  • 3.3k

How to Free memory after a form is closed (C# Win Forms)

Oct 30 2020 1:40 AM
Hello,
 
I am building a Kiosk type of application where the user Navigates using Next and Previous buttons. Many child forms (form objects) are created everytime the user presses Next/Previous buttons. Before opening another form, I close / dispose the present form. I am also calling the GC.collect() method. But the RAM usage keeps on increasing. 
 
As the application runs 24x7, over a period of time the application becomes sluggish. At the start of the application it consumes around 20MB, but within 24 hrs, the RAM usage shoots up to 300 MB.
 
Note : The forms are opened using ShowDialog method. 
 
What is the best way to resolve these issues ?? 
 
Thanks 

Answers (3)