Is it possible to call the GarbageCollector of an other process!
-
Hello everybody! I was searching threw System.GC and System.Diagnostics.Process but couldn't find something usefull. So I was wondering if it's possible to call the GC of an other managed process over an API or something I couldn't figure out? The question is out of curiosity, because I was wondering how the ".Net Memory Profiler" does the GC.Collect over all generation, when it's performing a snapshot. Thank you for taking time! P.S.: The last year I was not an active member of the community, cause I changed job and domicile. I changed now to unmanaged programing.
All the best, Martin
-
Hello everybody! I was searching threw System.GC and System.Diagnostics.Process but couldn't find something usefull. So I was wondering if it's possible to call the GC of an other managed process over an API or something I couldn't figure out? The question is out of curiosity, because I was wondering how the ".Net Memory Profiler" does the GC.Collect over all generation, when it's performing a snapshot. Thank you for taking time! P.S.: The last year I was not an active member of the community, cause I changed job and domicile. I changed now to unmanaged programing.
All the best, Martin
I'm not sure, I guess it may be possible to tell the GC to collect for everyone, but, telling it to collect at all is typically a bad thing to do in any case.
Christian Graus Driven to the arms of OSX by Vista.
-
I'm not sure, I guess it may be possible to tell the GC to collect for everyone, but, telling it to collect at all is typically a bad thing to do in any case.
Christian Graus Driven to the arms of OSX by Vista.
Hello Christian, Thanks for your quick answere!
Christian Graus wrote:
I'm not sure, I guess it may be possible to tell the GC to collect for everyone
I will have a look of the GC members again.
Christian Graus wrote:
but, telling it to collect at all is typically a bad thing to do in any case.
Yes it is! Maybe there are some other suggestions on that!
All the best, Martin
-
Hello everybody! I was searching threw System.GC and System.Diagnostics.Process but couldn't find something usefull. So I was wondering if it's possible to call the GC of an other managed process over an API or something I couldn't figure out? The question is out of curiosity, because I was wondering how the ".Net Memory Profiler" does the GC.Collect over all generation, when it's performing a snapshot. Thank you for taking time! P.S.: The last year I was not an active member of the community, cause I changed job and domicile. I changed now to unmanaged programing.
All the best, Martin
Martin# wrote:
I was searching threw System.GC and System.Diagnostics.Process but couldn't find something usefull. So I was wondering if it's possible to call the GC of an other managed process over an API or something I couldn't figure out?
No, you can't do that with the framework classes. You could of course expose a .NET object from your app and use remoting to talk to it, but that is way overkill, IMO.
Martin# wrote:
The question is out of curiosity, because I was wondering how the ".Net Memory Profiler" does the GC.Collect over all generation, when it's performing a snapshot.
There's a CLR Profiling API[^] that allows you to do things like that. You write a COM object that implements a bunch of callbacks, and then by setting an environment variable, it gets instantiated in the target process and can process notifications, as well as query for information. The API is very rich, I even wrote something that can find undisposed objects here[^].
Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro
-
Hello everybody! I was searching threw System.GC and System.Diagnostics.Process but couldn't find something usefull. So I was wondering if it's possible to call the GC of an other managed process over an API or something I couldn't figure out? The question is out of curiosity, because I was wondering how the ".Net Memory Profiler" does the GC.Collect over all generation, when it's performing a snapshot. Thank you for taking time! P.S.: The last year I was not an active member of the community, cause I changed job and domicile. I changed now to unmanaged programing.
All the best, Martin
Hi Martin(ex#), how are you doing? There are overloads of GC.Collect() that help you in collecting the generations within your own process (which you should not do). I suggest you don't start collecting garbage from others, there still is interesting stuff within IT. :laugh:
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
-
Hi Martin(ex#), how are you doing? There are overloads of GC.Collect() that help you in collecting the generations within your own process (which you should not do). I suggest you don't start collecting garbage from others, there still is interesting stuff within IT. :laugh:
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
Hi Luc! I'm doing very fine, thank you. Hope you are also doing well. I recognized that you where off-codeproject for a while. But it's good to see you back! No worry about me collecting garbage! :-D I'm just interested how programs like the ".Net Memory Profiler" doing this task. Wish you a nice weekend!
All the best, Martin
-
Martin# wrote:
I was searching threw System.GC and System.Diagnostics.Process but couldn't find something usefull. So I was wondering if it's possible to call the GC of an other managed process over an API or something I couldn't figure out?
No, you can't do that with the framework classes. You could of course expose a .NET object from your app and use remoting to talk to it, but that is way overkill, IMO.
Martin# wrote:
The question is out of curiosity, because I was wondering how the ".Net Memory Profiler" does the GC.Collect over all generation, when it's performing a snapshot.
There's a CLR Profiling API[^] that allows you to do things like that. You write a COM object that implements a bunch of callbacks, and then by setting an environment variable, it gets instantiated in the target process and can process notifications, as well as query for information. The API is very rich, I even wrote something that can find undisposed objects here[^].
Regards Senthil [MVP - Visual C#] _____________________________ My Home Page |My Blog | My Articles | My Flickr | WinMacro
Hello Senthil, Thank you very much for your valuable input! Just had a short look. It's really powerfull for getting informations! But I think there has to be a way forcing the GC on the other process. If I do a snapshot with the profiler it automaticaly makes a GC.Collect (GEN#2). EDIT Start: Just had a closer look, and I think a havent understood it at the first hand! I will give it a try, and let you know if it works for me. EDIT End:
S. Senthil Kumar wrote:
wrote something that can find undisposed objects here[^].
Very interesting, thanks for the link. Have a nice day!
All the best, Martin
modified on Friday, March 20, 2009 11:22 AM