Reputation: 1572
I'm making a C# Windows Forms Application that uses a large number of embedded resources(images,icons,...).After a long time editing,adding and removing objects from forms , many resources are not used at current time.I tried to delete unused resources myself but i found it too hard to do that as i can't remember all unused resources in my project.Is there an easy way to find or delete unused resources from my project ?
Upvotes: 1
Views: 1249
Reputation: 30892
You should ensure all of those resources are implementing IDisposable and use them from within a using()
block.
Example from MSDN:
using (Font font1 = new Font("Arial", 10.0f))
{
//font1 will have it's Dispose() method automatically called afterwards
}
This way you never have to remember to dispose of those resources, as they will happen automatically.
Don't forget the Garbage Collector will also clear out objects which are no longer referenced, it's the beauty of coding within a managed environment!
Upvotes: 1