Is it possible to run .NET garbage collector from command line, e.g. without writing code?
+6
A:
The garbage collector runs inside a process. So if you want to run the garbage collector for this process you could try the GC.Collect method. You cannot force garbage collection for a given process from the outside.
Also note that forcing garbage collection (using the GC.Collect
) method is considered as bad practice and should be avoided.
There is no Microsoft tool and I have never heard of any 3rd party tool capable of doing this. Each process gets its own GC heaps, and therefore its own GC threads, so forcing a GC Collection on another process, AFAIK, is impossible.
Darin Dimitrov
2010-08-29 08:29:35
Thanks, but as I asked in the question: "without writing code". I assume that there any tool, that I can call from command line for some specific process. So sorry, your answer is not relevant.
Kamarey
2010-08-29 08:32:04
@Kamarey, there is no Microsoft tool (and I doubt any 3rd party tool exists). Each process gets its own GC heaps, and therefore its own GC threads, so forcing a GC Collection on anotherprocess, as far as I know, is impossible.
Darin Dimitrov
2010-08-29 08:34:58
@Kamarey how is it not relevant stating no it can't be done and giving you the reason?
Rune FS
2010-08-29 08:36:18
Ok, thanks. So can you replace your answer with your last comment, so it will answer my question?
Kamarey
2010-08-29 08:39:23
@Rune FS: sorry, I don't get your english. Can you explain what the problem?
Kamarey
2010-08-29 08:40:32
@Kamarey, updated answer to include my comment.
Darin Dimitrov
2010-08-29 08:42:42