473,394 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Is IDisposable.Dispose() deterministic for managed resources?

For instance:

component.Dispose(); will this lead to resources beginning to be
released immediately after the method is called, as opposed to relying
on GC?
Jun 18 '06 #1
3 1616
Roughly it will release resourece immediately.

Concretely it will only release immediately resource that can be relesed
immediately, that is native resource.
Managed memory use by the managed object will only be claimed when:
1. the object will stopped being referenced
2. and the GC kicks-in...

"antoan" <an****@antoan.plus.com> wrote in message
news:44***********************@ptn-nntp-reader01.plus.net...
For instance:

component.Dispose(); will this lead to resources beginning to be released
immediately after the method is called, as opposed to relying on GC?

Jun 18 '06 #2
>component.Dispose(); will this lead to resources beginning to be
released immediately after the method is called, as opposed to relying
on GC?


Dispose will release native resources held directly or indirectly. It
will not affect when an object is garbage collected.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jun 18 '06 #3
"antoan" <an****@antoan.plus.com> wrote in message
news:44***********************@ptn-nntp-reader01.plus.net...
For instance:

component.Dispose(); will this lead to resources beginning to be released
immediately after the method is called, as opposed to relying on GC?


If you mean managed resources created by "component", they'll be released
(Dispose'd) in Dispose only if you make it so.

Or I misunderstood you. :)

///ark
Jun 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

26
by: codymanix | last post by:
Last night I had several thought about RAII and want to discuss a bit. Why doesn't CSharp support destructors in structs? Wouldn't that make RAII possible like in C++? When the struct goes out of...
24
by: Jazper | last post by:
hi i have this problem. i made a class deverted by CRootItem with implementation of IDisposable-Interface. i made a test-funktion to test my Dispose-Method.... but when set a breakpoint in my...
5
by: Samuel R. Neff | last post by:
I'd like some opinions on whether or not to use IDisposable for classes that require clean-up but when the clean-up is not related to unmanaged resources or other disposable objects. The most...
2
by: Brian Henry | last post by:
when you make a class implement IDisposable, is that basicly the same thing as a destructor implementation in C++? it seems ot just add a dispose method to a class, which in C++ that'd be a...
9
by: CMirandaman | last post by:
Perhaps someone can help me understand this. I'm trying to understand what the IDisposable interface actually does because as far as I can tell it seems to be just garnish on the plate. If I...
4
by: Helge Jensen | last post by:
In C# 2.0 System.IO.Stream is declared as: public class Stream: ..., IDisposable { ... public void Dispose(); public void Dispose(bool); IDisposable.Dispose(); } Which must be a...
4
by: phl | last post by:
hi, My question is: 1. To avoid possible memory leaks, when you use this pattern, after you have dealth with the unmanaged resources and before you take your object off the finalize queue,...
6
by: Water Cooler v2 | last post by:
I heard from someone that we must not implement IDisposable for all classes. Can someone please tell me: 1. the reason why we must not implement IDisposable for all the classes we write. 2....
12
by: Cordell Lawrence \(News Group\) | last post by:
There an ongoing discussion between a colleague and myself about the usefulness of the IDisposable pattern beyond the reclamation of unmanaged resources. The discussion is somewhat lengthy so I...
47
by: Hilton | last post by:
Hi, I'm sure I'm simplifying things here, but how about if the GC did this to objects that implement IDisposable: 1. Always Generation 1 (I think that is the correct name) 2. Get aggressive...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.