c# - How soon after disposing is memory available? -


is instantaneous after gc runs?

i monitoring memory (available mbytes) using perfmon while running application i'm working on. loaded files see available mbytes going down expected, closed them didn't go i'm wondering if not disposing correctly or if there else affects this.

when file loaded:

  • the contents stored in objects
  • a new instance of usercontrol created
  • a new tabpage created
  • the usercontrol added tabpage
  • the tabpage added tabcontrol

reading on saw 1 of common things can cause memory leaks not unsubscribing event handlers , made sure did in usercontrol's dispose method. subscribe 'removingtab' event of tabcontrol tabpages have no attached handlers.

when closing file, remove stored instances of objects , call dispose on both usercontrol , tabpage. tried running clr profiler (which haven't had experience with) , said there no gc runs.

another common source of memory not being released holding onto unmanaged resources, open files being 1 example.

the memory available after gc cleans whatever using it. not every gc run results in memory being released. object survives @ least 1 gc run can end living long time because it's no longer in generation 0 - end being around until app needs more memory available it. large objects (larger 85kb, far remember) stored on large object heap isn't part of every gc run.

your best bet @ holding memory. use visual studio performance tools or try perfview. once know holding memory you'll in better position figure out how released.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -