Generic list & dispose

  • Thread starter Thread starter Micha³ Sakowicz
  • Start date Start date
M

Micha³ Sakowicz

Hi,

I have quick question, I've created user control which is using
generic lists internally. Should I implement IDisposable pattern to
release memory taken by those lists, or should I leave it as it is and
let GC do its job? I'm not using any unmanaged resources.

Thanks
Michal
 
I have quick question, I've created user control which is using
generic lists internally. Should I implement IDisposable pattern to
release memory taken by those lists, or should I leave it as it is and
let GC do its job? I'm not using any unmanaged resources.

I wouldn't bother. It will be GC'd when appropriate. You could, if you
wish, clear the list from the Dispose() method on your control.



Pete
 
It is good practice to especially if the list is large and don't forget this
is running on a memory contrained device. It is better to clear memory as
soon as possible IMO. As Peter suggested, implement the IDisposable on the
Control and in the Dispose method clear the list from there.
 
Back
Top