473,499 Members | 1,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MVP's Please respond!

Hi All, To my correct understanding Garbage Collection works based on
Generation algorithm...(high level).
I have an application which does some heavy operations usually File I/O's. I
want to force garbage collection on this class. I still want the GC to
release all resources before finalizing etc...but I want GC to kick in ASAP,
rather waiting to execute its algo to detect that this class needs cleaning
up and finally come to its rescue...

This is what I have implemented. Please advice

TIA

class Foo:IDisposable
{

public void Dispose()
{
GC.Collect();
}

}
Nov 16 '05 #1
2 1191
Hi Vai2000 ,

Take a look at System.GC class. It has methods:
GC.Collect() to force grabage collection
GC.WaitForPandingFinalizers() - after calling GC.Collect it will block until
all finalizers finish.

--
HTH
Stoitcho Goutsev (100) [C# MVP]
"Vai2000" <no****@microsoft.com> wrote in message
news:OQ**************@TK2MSFTNGP12.phx.gbl...
Hi All, To my correct understanding Garbage Collection works based on
Generation algorithm...(high level).
I have an application which does some heavy operations usually File I/O's. I want to force garbage collection on this class. I still want the GC to
release all resources before finalizing etc...but I want GC to kick in ASAP, rather waiting to execute its algo to detect that this class needs cleaning up and finally come to its rescue...

This is what I have implemented. Please advice

TIA

class Foo:IDisposable
{

public void Dispose()
{
GC.Collect();
}

}

Nov 16 '05 #2
[For future reference - it would be better to give a subject line which
actually describes your problem. You may also have alienated others who
have a perfectly good answer but aren't MVPs.]

Vai2000 <no****@microsoft.com> wrote:
Hi All, To my correct understanding Garbage Collection works based on
Generation algorithm...(high level).
I have an application which does some heavy operations usually File I/O's. I
want to force garbage collection on this class. I still want the GC to
release all resources before finalizing etc...but I want GC to kick in ASAP,
rather waiting to execute its algo to detect that this class needs cleaning
up and finally come to its rescue...

This is what I have implemented. Please advice

class Foo:IDisposable
{
public void Dispose()
{
GC.Collect();
}
}


That looks like a very bad idea to me. Why do you think it's a good
idea to force garbage collection? Much better would be to call Dispose
on all the appropriate streams explicitly. That will release the
unmanaged resources but not force a potentially expensive garbage
collection.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3

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

Similar topics

16
3899
by: Thomas G. Marshall | last post by:
This message is sent to these newsgroups because they are no longer valid: comp.lang.java comp.lang.java.api comp.lang.java.bugs comp.lang.java.misc comp.lang.java.setup comp.lang.java.tech
0
1103
by: eric cocozza | last post by:
Hi, I just moved a python program to a new server, and I'm getting path errors. It relys on the pear library and a image processing one. Please respond with cost based on 1/hr of work, and...
26
2907
by: Michael Strorm | last post by:
Hi! I posted a message a while back asking for project suggestions, and decided to go with the idea of creating an adventure game (although it was never intended to be a 'proper' game, rather an...
2
1069
by: Amit D.Shinde | last post by:
I can see many MVP answers my doubts..Thanks to all Members of Newsgroup Can any one of you tell me what's MVP and what are its requirements? How to register to become a MVP
3
1345
by: Ron | last post by:
How to handle this when using custom membership provider. Please refer to my first question which is posted. "Custom Membership Provider" Thanks, Ron
18
2176
by: Chris Hills | last post by:
A lesson in Posting How many C.L.C group posters does it take to change a C light bulb? 1 to change the light bulb and to post that the light bulb has been changed 14 to share similar...
31
1635
by: Simply_Red | last post by:
i'm sorry i posted this in other groupes, and i didn't see it, and as this group is most actif, i repost it here, and sorry for mutliposting: Hi, i'm using VC6, i have this declaration: ...
12
1475
by: Zilla | last post by:
I put everything in one file for ease of use; also I have #include <*.hfiles instead of the <*since my compiler is pre-ANSI C so it needs the .h #include <iostream.h> #include <iomanip.h>...
2
5529
by: blogman | last post by:
I am getting a Visual studio 2008 IDE application R6034 runtime error. This means that the IDE application is raising the error not the application I am building. This means that Microsoft did not...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6894
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...
0
7388
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5470
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
297
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.