"Sput" <sp********@post.htnet.hr> wrote in message news:<bu**********@ls219.htnet.hr>...
I have a program with many forms which users are often opening and closing.
Now, I have noticed that after opening 10 different forms and the closing
them, memory consumption increases (eg. it has 25mb before opening 10 forms,
then while they are open it has 26mb, after closing it has 25.8mb)
After user is working for several hours, mem. usage jumpes to 70-100mb.
Should I manually clean up after form closes or does the garbage collector
clean everything?
(ie there is a lot of graphics loaded from outside on forms and maybe gc
does not dispose of them - entirely?)
Garbage collector won't collect memory till it doesn't feel the need
of it. Internally, how that feel is decided, We don't know. If you
have lot's of ram and few programs running, it may not tend to free up
resources.
Few points:
- Just check if you are using destructurs in your forms or classes
Internally they get converted to Finalize method, and such classes
gets promoted to longer generation, remaining in memory for more time.
If it is so, try overriding Dispose method also, and call it when you
are done with resources.
- You can manually call GC.
As you are working with manual interaction, you must have plenty of
time, when much is not being done and you call GC as static method
System.GC.Collect();
System.GC.WaitForPendingFinalizers();
Have a nice day
Manish Singh