Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Is it possible to call the GarbageCollector of an other process!

Is it possible to call the GarbageCollector of an other process!

Scheduled Pinned Locked Moved C#
questioncsharpalgorithmsjsonperformance
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Martin 0
    wrote on last edited by
    #1

    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

    C S L 3 Replies Last reply
    0
    • M Martin 0

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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.

      M 1 Reply Last reply
      0
      • C Christian Graus

        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.

        M Offline
        M Offline
        Martin 0
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • M Martin 0

          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

          S Offline
          S Offline
          S Senthil Kumar
          wrote on last edited by
          #4

          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

          M 1 Reply Last reply
          0
          • M Martin 0

            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

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            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


            M 1 Reply Last reply
            0
            • L Luc Pattyn

              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


              M Offline
              M Offline
              Martin 0
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              • S S Senthil Kumar

                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

                M Offline
                M Offline
                Martin 0
                wrote on last edited by
                #7

                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

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups