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. .NET (Core and Framework)
  4. Weird garbage collection

Weird garbage collection

Scheduled Pinned Locked Moved .NET (Core and Framework)
comcsharpdotnetdata-structurestesting
3 Posts 3 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.
  • S Offline
    S Offline
    solidstore
    wrote on last edited by
    #1

    I have a simple C# Windows Service which exposes some objects via remoting. These objects are also registered for COM Interop. I have a test web ASP page which creates the COM objects (which run remotely inside my service). Every thing has been running fine until we started stress testing. The service's memory increases until the box is on its knees whilst we run even a light test. However, here the strange bit, if I change the service process's start Main function to just sit and wait on a MessageBox.Show call instead of running as a service the test still runs perfectly well but the memory usage does not climb, it remains stable. Using perfmon viewing the CLR Memory/#bytes in all heaps we see a nice zig-zag pattern of allocs followed by garbage collection. When running as a service the perfmon graph just increases ever upwards. It seems as though garbage collection doesnt happen when remoting objects from a service? Any thoughts or similar experience?

    T 1 Reply Last reply
    0
    • S solidstore

      I have a simple C# Windows Service which exposes some objects via remoting. These objects are also registered for COM Interop. I have a test web ASP page which creates the COM objects (which run remotely inside my service). Every thing has been running fine until we started stress testing. The service's memory increases until the box is on its knees whilst we run even a light test. However, here the strange bit, if I change the service process's start Main function to just sit and wait on a MessageBox.Show call instead of running as a service the test still runs perfectly well but the memory usage does not climb, it remains stable. Using perfmon viewing the CLR Memory/#bytes in all heaps we see a nice zig-zag pattern of allocs followed by garbage collection. When running as a service the perfmon graph just increases ever upwards. It seems as though garbage collection doesnt happen when remoting objects from a service? Any thoughts or similar experience?

      T Offline
      T Offline
      The Limey
      wrote on last edited by
      #2

      I had a similar problem. It turned out to be the Com object. The GC tidies up whenever it likes unless you force it. I tried everything getting the handle of the com destroying implicitly, forcing GC nohing worked. Once the com instance was created there was no way in hell to destroy it. Funnily enough it wasn't even a custom com it was Microsoft's own!. It looks exactly the same problem as you are having. Never did cure it. Sorry could not help He who laughs last thinks slowest.

      S 1 Reply Last reply
      0
      • T The Limey

        I had a similar problem. It turned out to be the Com object. The GC tidies up whenever it likes unless you force it. I tried everything getting the handle of the com destroying implicitly, forcing GC nohing worked. Once the com instance was created there was no way in hell to destroy it. Funnily enough it wasn't even a custom com it was Microsoft's own!. It looks exactly the same problem as you are having. Never did cure it. Sorry could not help He who laughs last thinks slowest.

        S Offline
        S Offline
        Simon Gregory
        wrote on last edited by
        #3

        We use System.Runtime.Marshal.Cantremembetthisbit.ReleaseComObject() which seems to clean up on the spot.

        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