473,287 Members | 1,866 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,287 software developers and data experts.

Force garbage collection on a process

Is there a utility by microsoft (or anyone) to force garbage collection in a
process without have access to the process code.

regards
Ganesh
Nov 22 '05 #1
6 11478
Hey Ganesh,

The Sysem namespace has a GC class, which has a collect method...

GC.Collect()

Check the help under Garbage Collection, subtopic: Forcing Garbage
Collection.

HTH,

John

"Ganesh" <gr******@yahoo.com> wrote in message
news:uS**************@TK2MSFTNGP10.phx.gbl...
Is there a utility by microsoft (or anyone) to force garbage collection in a process without have access to the process code.

regards
Ganesh

Nov 22 '05 #2
Hi Ganesh

There is no Microsoft tool (and I doubt any 3rd party tool exists). Each process gets its own GC Heap(s), and therefore its own GC Thread(s), so forcing a GC Collection on another
process, as far as I know, is impossible. It's probably not really desirable, since the GC is self-tuning and can decide when to collect based on memory pressure and allocation
patterns (among other things).

-Chris

--------------------
From: "Ganesh" <gr******@yahoo.com>
Subject: Force garbage collection on a process
Date: Tue, 27 Jul 2004 11:44:18 -0700
Lines: 7
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <uS**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.general
NNTP-Posting-Host: ext-nat.kla-tencor.com 192.146.1.254
Path: cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.general:140942
X-Tomcat-NG: microsoft.public.dotnet.general

Is there a utility by microsoft (or anyone) to force garbage collection in a
process without have access to the process code.

regards
Ganesh

--

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.

Nov 22 '05 #3
Hi Chris,

I've got another questing about the garbage collector.
The application (a windows service app) I created runs fine on my
development system (Xp), consumes ~50Mb ram and seems to collect garbage
just fine. Running the same app on a production server (W2000 Server) the
process keeps consuming more and more memory. I made sure there is no memory
leak in the application. After running a memory profiler I found out gen2
garbage collection is not happening (enough). The application continues to
consume memory until system resources are empty and the server slows down
tremendously.
The app in question is an network management application and is searching
the network for devices/components. The development system uses the same
network for testing (=same environment).
Both systems have the same amount of physical memory. Development server
shows ~50mb memory and 50Mb virtual memory usage. Production server ~800Mb
memory, 500-1000Mb virtual.

Any tips/hints on how to solve this issue?

Erik Tamminga
MCSD

""Chris Lyon [MSFT]"" <cl***@online.microsoft.com> wrote in message
news:4%****************@cpmsftngxa10.phx.gbl...
Hi Ganesh

There is no Microsoft tool (and I doubt any 3rd party tool exists). Each process gets its own GC Heap(s), and therefore its own GC Thread(s), so
forcing a GC Collection on another process, as far as I know, is impossible. It's probably not really desirable, since the GC is self-tuning and can decide when to collect based
on memory pressure and allocation patterns (among other things).

-Chris

--------------------
From: "Ganesh" <gr******@yahoo.com>
Subject: Force garbage collection on a process
Date: Tue, 27 Jul 2004 11:44:18 -0700
Lines: 7
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <uS**************@TK2MSFTNGP10.phx.gbl>
Newsgroups: microsoft.public.dotnet.general
NNTP-Posting-Host: ext-nat.kla-tencor.com 192.146.1.254
Path: cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP10
..phx.gblXref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.general:140942
X-Tomcat-NG: microsoft.public.dotnet.general

Is there a utility by microsoft (or anyone) to force garbage collection in aprocess without have access to the process code.

regards
Ganesh


--

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.

Nov 22 '05 #4
Hi Erik

A couple of things you might want to try:
-What version of the runtime are you using? v1.1 has better large memory management than v1.0.
-Is your service running with Workstation or Server GC? You'll get better throughput with Server GC (you can specify this by hosting the runtime. See
http://msdn.microsoft.com/msdnmag/is...r/default.aspx)
-If possible, wait for the latest service packs due this summer (v1.0 SP3, v1.1 SP1)
-Take a look at Rico Mariani's blog (http://weblogs.asp.net/ricom/), in particular posts about recycling objects (http://weblogs.asp.net/ricom/archive.../11/71143.aspx)
and midlife crisis (http://weblogs.asp.net/ricom/archive.../04/41281.aspx)

Hope that helps!
-Chris
--------------------
From: "Erik Tamminga" <REVERSE_THIS_agnimmate@REVERSE_THIS_nerrats.ln>
References: <uS**************@TK2MSFTNGP10.phx.gbl> <4#**************@cpmsftngxa10.phx.gbl>
Subject: Re: Force garbage collection on a process
Date: Wed, 28 Jul 2004 13:04:10 +0200
Lines: 78
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <OB**************@TK2MSFTNGP09.phx.gbl>
Newsgroups: microsoft.public.dotnet.general
NNTP-Posting-Host: wc-130.r-195-35-168.essentkabel.com 195.35.168.130
Path: cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP09.phx.gbl
Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.general:140992
X-Tomcat-NG: microsoft.public.dotnet.general

Hi Chris,

I've got another questing about the garbage collector.
The application (a windows service app) I created runs fine on my
development system (Xp), consumes ~50Mb ram and seems to collect garbage
just fine. Running the same app on a production server (W2000 Server) the
process keeps consuming more and more memory. I made sure there is no memory
leak in the application. After running a memory profiler I found out gen2
garbage collection is not happening (enough). The application continues to
consume memory until system resources are empty and the server slows down
tremendously.
The app in question is an network management application and is searching
the network for devices/components. The development system uses the same
network for testing (=same environment).
Both systems have the same amount of physical memory. Development server
shows ~50mb memory and 50Mb virtual memory usage. Production server ~800Mb
memory, 500-1000Mb virtual.

Any tips/hints on how to solve this issue?

Erik Tamminga
MCSD

""Chris Lyon [MSFT]"" <cl***@online.microsoft.com> wrote in message
news:4%****************@cpmsftngxa10.phx.gbl...
Hi Ganesh

There is no Microsoft tool (and I doubt any 3rd party tool exists). Each

process gets its own GC Heap(s), and therefore its own GC Thread(s), so
forcing a GC Collection on another
process, as far as I know, is impossible. It's probably not really

desirable, since the GC is self-tuning and can decide when to collect based
on memory pressure and allocation
patterns (among other things).

-Chris

--------------------
>From: "Ganesh" <gr******@yahoo.com>
>Subject: Force garbage collection on a process
>Date: Tue, 27 Jul 2004 11:44:18 -0700
>Lines: 7
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
>Message-ID: <uS**************@TK2MSFTNGP10.phx.gbl>
>Newsgroups: microsoft.public.dotnet.general
>NNTP-Posting-Host: ext-nat.kla-tencor.com 192.146.1.254
>Path:cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSF TNGP08.phx.gbl!TK2MSFTNGP10
.phx.gbl >Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.general:140942
>X-Tomcat-NG: microsoft.public.dotnet.general
>
>Is there a utility by microsoft (or anyone) to force garbage collectionin a >process without have access to the process code.
>
>regards
>Ganesh
>
>
>

--

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.


--

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.

Nov 22 '05 #5
Hi Shreeman

No, the GC doesn't only collect when the system is idle. If necessary, the GC will pause execution of the application to collect, depending on the GC mode used (on multiproc
machines, Concurrent GC does collections without pausing the application, making it ideal for interactive apps).

Also, collections don't only occur when the system is low on memory. Collections usually happen when an allocation into a particular generation fail. See
http://msdn.microsoft.com/msdnmag/issues/1100/gci/ for more info.

-Chris

--------------------

hi
Though i am not an expert i can share some of my exp on same.while searching the network using wmi and adsi i faced similar problem but my problem was not garbage collection as i have written a certain service for that and i have disposed my individual instances myself.
so since the garbage collection works only when the system idle and low of memory so will it not be better to componentise ur apps and just the parts ince you are over with it.

may be i am wrong?If you ve solved or have any bettere idea .
mail to me.
i ll be more happy for any comments anfd suggestions.
bye
shreeman
sn*********@rediffmail.com

"Erik Tamminga" wrote:
Hi Chris,

I've got another questing about the garbage collector.
The application (a windows service app) I created runs fine on my
development system (Xp), consumes ~50Mb ram and seems to collect garbage
just fine. Running the same app on a production server (W2000 Server) the
process keeps consuming more and more memory. I made sure there is no memory
leak in the application. After running a memory profiler I found out gen2
garbage collection is not happening (enough). The application continues to
consume memory until system resources are empty and the server slows down
tremendously.
The app in question is an network management application and is searching
the network for devices/components. The development system uses the same
network for testing (=same environment).
Both systems have the same amount of physical memory. Development server
shows ~50mb memory and 50Mb virtual memory usage. Production server ~800Mb
memory, 500-1000Mb virtual.

Any tips/hints on how to solve this issue?

Erik Tamminga
MCSD

""Chris Lyon [MSFT]"" <cl***@online.microsoft.com> wrote in message
news:4%****************@cpmsftngxa10.phx.gbl...
> Hi Ganesh
>
> There is no Microsoft tool (and I doubt any 3rd party tool exists). Each

process gets its own GC Heap(s), and therefore its own GC Thread(s), so
forcing a GC Collection on another
> process, as far as I know, is impossible. It's probably not really

desirable, since the GC is self-tuning and can decide when to collect based
on memory pressure and allocation
> patterns (among other things).
>
> -Chris
>
> --------------------
> >From: "Ganesh" <gr******@yahoo.com>
> >Subject: Force garbage collection on a process
> >Date: Tue, 27 Jul 2004 11:44:18 -0700
> >Lines: 7
> >X-Priority: 3
> >X-MSMail-Priority: Normal
> >X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
> >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
> >Message-ID: <uS**************@TK2MSFTNGP10.phx.gbl>
> >Newsgroups: microsoft.public.dotnet.general
> >NNTP-Posting-Host: ext-nat.kla-tencor.com 192.146.1.254
> >Path:

cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP10
..phx.gbl
> >Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.general:140942
> >X-Tomcat-NG: microsoft.public.dotnet.general
> >
> >Is there a utility by microsoft (or anyone) to force garbage collection

in a
> >process without have access to the process code.
> >
> >regards
> >Ganesh
> >
> >
> >
>
>
> --
>
> 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.
>


--

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.

Nov 22 '05 #6
Thanks Chris.
I was facing a similar problem that Erik was facing with the gen2 not being
cleaned up.

Will try out the workarounds given here

thanks
Ganesh
""Chris Lyon [MSFT]"" <cl***@online.microsoft.com> wrote in message
news:FD**************@cpmsftngxa10.phx.gbl...
Hi Erik

A couple of things you might want to try:
-What version of the runtime are you using? v1.1 has better large memory management than v1.0. -Is your service running with Workstation or Server GC? You'll get better throughput with Server GC (you can specify this by hosting the runtime. See http://msdn.microsoft.com/msdnmag/is...r/default.aspx)
-If possible, wait for the latest service packs due this summer (v1.0 SP3, v1.1 SP1) -Take a look at Rico Mariani's blog (http://weblogs.asp.net/ricom/), in particular posts about recycling objects
(http://weblogs.asp.net/ricom/archive.../11/71143.aspx) and midlife crisis (http://weblogs.asp.net/ricom/archive.../04/41281.aspx)
Hope that helps!
-Chris
--------------------
From: "Erik Tamminga" <REVERSE_THIS_agnimmate@REVERSE_THIS_nerrats.ln>
References: <uS**************@TK2MSFTNGP10.phx.gbl> <4#**************@cpmsftngxa10.phx.gbl>Subject: Re: Force garbage collection on a process
Date: Wed, 28 Jul 2004 13:04:10 +0200
Lines: 78
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <OB**************@TK2MSFTNGP09.phx.gbl>
Newsgroups: microsoft.public.dotnet.general
NNTP-Posting-Host: wc-130.r-195-35-168.essentkabel.com 195.35.168.130
Path: cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP09
..phx.gblXref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.general:140992
X-Tomcat-NG: microsoft.public.dotnet.general

Hi Chris,

I've got another questing about the garbage collector.
The application (a windows service app) I created runs fine on my
development system (Xp), consumes ~50Mb ram and seems to collect garbage
just fine. Running the same app on a production server (W2000 Server) the
process keeps consuming more and more memory. I made sure there is no memoryleak in the application. After running a memory profiler I found out gen2
garbage collection is not happening (enough). The application continues toconsume memory until system resources are empty and the server slows down
tremendously.
The app in question is an network management application and is searching
the network for devices/components. The development system uses the same
network for testing (=same environment).
Both systems have the same amount of physical memory. Development server
shows ~50mb memory and 50Mb virtual memory usage. Production server ~800Mbmemory, 500-1000Mb virtual.

Any tips/hints on how to solve this issue?

Erik Tamminga
MCSD

""Chris Lyon [MSFT]"" <cl***@online.microsoft.com> wrote in message
news:4%****************@cpmsftngxa10.phx.gbl...
Hi Ganesh

There is no Microsoft tool (and I doubt any 3rd party tool exists). Each
process gets its own GC Heap(s), and therefore its own GC Thread(s), so
forcing a GC Collection on another
process, as far as I know, is impossible. It's probably not reallydesirable, since the GC is self-tuning and can decide when to collect basedon memory pressure and allocation
patterns (among other things).

-Chris

--------------------
>From: "Ganesh" <gr******@yahoo.com>
>Subject: Force garbage collection on a process
>Date: Tue, 27 Jul 2004 11:44:18 -0700
>Lines: 7
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
>Message-ID: <uS**************@TK2MSFTNGP10.phx.gbl>
>Newsgroups: microsoft.public.dotnet.general
>NNTP-Posting-Host: ext-nat.kla-tencor.com 192.146.1.254
>Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSF TNGP08.phx.gbl!TK2MSFTNGP1

0.phx.gbl
>Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.general:140942
>X-Tomcat-NG: microsoft.public.dotnet.general
>
>Is there a utility by microsoft (or anyone) to force garbage
collectionin a
>process without have access to the process code.
>
>regards
>Ganesh
>
>
>
--

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.


--

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.

Nov 22 '05 #7

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

Similar topics

6
by: Ganesh | last post by:
Is there a utility by microsoft (or anyone) to force garbage collection in a process without have access to the process code. regards Ganesh
24
by: Yang | last post by:
I found a very strange behavior when I write a C# windows application. If I allocate a huge chunk of memory by an array, the memory will never be released by .NET. The problem can be demostrated...
2
by: Oculus | last post by:
Before I get into the question -- I know .NET isn't the right solution for this app but it's part of my clients requirements and writing this in C++ isn't an option. That being said -- my app is a...
3
by: Cheung, Jeffrey Jing-Yen | last post by:
Hi all, I need some help with debugging a "deadlock" in a production environment. I've managed to get a crash dump and have tried to analyzed it via WinDbg and SOS. Unfortunately, I am not...
8
by: mike2036 | last post by:
For some reason it appears that garbage collection is releasing an object that I'm still using. The object is declared in a module and instantiated within a class that is in turn instantiated by...
18
by: Larry Herbinaux | last post by:
I'm having issues with garbage collection with my long-standing service process. If you could review and point me in the right direction it would be of great help. If there are any helpful...
1
by: dd | last post by:
I have a situation where the browser memory goes up and up as each Ajax call causes new content to be deployed into a DIV. I'd like to know if I can force garbage collection to occur. More...
2
by: roger.dunham | last post by:
I am trying to identify whether a .NET 1.1 application that I have written has a memory leak. I thought I understood how .NET memory management worked, but it appears that there is more to it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...

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.