Hi Barry
Most of the classes in the .NET Framework that have finalizers also implement the IDisposable interface, and inside the Dispose method is a call to GC.SuppressFinalize. As a
user, you should not be calling SuppressFinalize on Framework classes, you just need to properly use the Dispose pattern.
More infor ont he Dispose pattern:
http://msdn.microsoft.com/library/de...izedispose.asp
Hope that helps
-Chris
--------------------
From: ba******@yahoo.com (Barry Anderberg)
Newsgroups: microsoft.public.dotnet.general
Subject: Question about Finalize & SuppressFinalize
Date: 10 May 2004 13:19:35 -0700
Organization: http://groups.google.com
Lines: 23
Message-ID: <9d**************************@posting.google.com >
NNTP-Posting-Host: 65.214.110.254
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1084220376 14778 127.0.0.1 (10 May 2004 20:19:36 GMT)
X-Complaints-To: gr**********@google.com
NNTP-Posting-Date: Mon, 10 May 2004 20:19:36 +0000 (UTC)
Path: cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFT NGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.com!newsfeed.icl.net!pr oxad.net!209.98.3.200.MISMATCH!
priapus.visi.com!orange.octanews.net!news.octanews .net!green.octanews.net!news-out.octanews.net!news.glorb.com!postnews1.google.c om!not-for-mailXref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.general:133629
X-Tomcat-NG: microsoft.public.dotnet.general
I've been doing some reading about Finalize and garbage collection.
I've learned that finalizing should be avoided because objects that
have a finalize method require 2 (possibly more) itterations of the
garbage collector to run before the memory is returned to the heap.
The first time the GC runs the Finalize method is called, then the
second time the memory is actually freed.
The problem is that most of the major classes in the .NET framework
have a Finalize method.
The System.Windows.Forms.Control and System.Windows.Forms.Form classes
BOTH have finalize methods.
Am I to understand that I should always call GC.SuppressFinalize after
creating these objects?
Otherwise from what I have read it will take two or MORE garbage
collection cycles to free the memory!!
This seems wrong. Why would MS do this? I don't think they would
which makes me think there's some part of the picture I don't get.
Help!
--
This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated.