Click here to Skip to main content
12,897,391 members (53,502 online)
Rate this:
Please Sign up or sign in to vote.
See more: performance
In order to Dispose an object , first the class referenced to that object must be inherited from Idisposable,.....

but once a class is inherited from Idisposable but If dispose() method is not explicitly called on object means , will that object gets disposed????

what is the use of IDisposable if class inherited from IDisposable but Dispose() is not used???
Posted 18-Oct-11 22:49pm
Updated 18-Oct-11 23:11pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Yes, it will - eventually.

If you do not use Dispose on an object that implements IDisposable, then it will be called automatically by the framework when the Garbage Collector realizes it is no longer needed and starts to delete it.

NOTE: This is not the same time as the object drops out of scope! The Garbage Collector may not get round to your object for hours, days or even weeks. If you create any object that implements IDisposable, then you are responsible for disposing of the object correctly, or problems can be expected. A simple example is to open a file for reading and not dispose of the stream object. If your application later tries to write to the file, it will get "File in use by another application" because the stream still exists (although it has no references) and is holding the file until the GC removes it. Frustrating, and annoying!
m19anand 19-Oct-11 5:04am
thanx for ur answer,....

but my case is, im unable to dispose the object of class which implements Idisposable , because the class is a Eileo class and data is cuming from eileo server so im unable to dispose the object of that class..

please give some suggetion
Rate this: bad
Please Sign up or sign in to vote.

Solution 2


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 19 Oct 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100