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. Blocking threads - growing memory

Blocking threads - growing memory

Scheduled Pinned Locked Moved C#
helpcomperformancequestion
2 Posts 2 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.
  • G Offline
    G Offline
    GDavy
    wrote on last edited by
    #1

    Hello, I have an annoying issue where I could use some advice. I created a small windows service which uses at standard time-intervals different COM components. Every time the COM components are instantiated in their own thread, the required methods are invoked and the COM components are subsequently released and their threads end, the main thread can then evaluate the result of each COM component's action. For some COM components(third party) a problem occurs from time to time and the instantiation of the COM object blocks the thread. Even calling an Abort on these threads is not possible because doing that causes the main-thread to block. The COM components are simply instantiated using: System.Activator.CreateInstance(comType); //here it blocks when it goes wrong (not always) The comType is gotten using: Type comType = Type.GetTypeFromProgID(sComName); //sComName is the name of the COM component If this blocking happens frequently, the memory of the process increases steadily due to all the blocked threads that I can't stop. So what I need is an ability to use the COM components, and still be able to clean up the threads in case such a block occurs. Does anyone have any ideas how I could accomplish that? Regards, Davy

    L 1 Reply Last reply
    0
    • G GDavy

      Hello, I have an annoying issue where I could use some advice. I created a small windows service which uses at standard time-intervals different COM components. Every time the COM components are instantiated in their own thread, the required methods are invoked and the COM components are subsequently released and their threads end, the main thread can then evaluate the result of each COM component's action. For some COM components(third party) a problem occurs from time to time and the instantiation of the COM object blocks the thread. Even calling an Abort on these threads is not possible because doing that causes the main-thread to block. The COM components are simply instantiated using: System.Activator.CreateInstance(comType); //here it blocks when it goes wrong (not always) The comType is gotten using: Type comType = Type.GetTypeFromProgID(sComName); //sComName is the name of the COM component If this blocking happens frequently, the memory of the process increases steadily due to all the blocked threads that I can't stop. So what I need is an ability to use the COM components, and still be able to clean up the threads in case such a block occurs. Does anyone have any ideas how I could accomplish that? Regards, Davy

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      GDavy wrote:

      Does anyone have any ideas how I could accomplish that?

      An ugly workaround, but you could consider putting them in a separate app and using IPC to communicate with the COM-component. Once the app seems to hang, you kill it :)

      I are Troll :suss:

      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