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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Dispose Generic List 3
Disposing EventHandlers 1
Dispose 9
ArrayList to List<myType> and item disposal 8
Idea: GC and IDisposable 52
Dispose, 1
Using dispose correctly 3
Dispose pattern 25

Back
Top