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. Restarting a service

Restarting a service

Scheduled Pinned Locked Moved C#
questionc++comperformance
5 Posts 3 Posters 2 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
    Mauricio Ritter
    wrote on last edited by
    #1

    I've created a windows service that as the time passes it start to consume a lot of memory. I'm using a managed zlib library for compression (one published here). I tried to force a garbage collection but it doesn't work. Question is: can I send a restart command to the service from within the service ? Mauricio Ritter - Brazil MSN: mauricioritter(atsign)hotmail.com
    English is not my native language so, if you find any spelling erros in my posts, please let me know.

    D 1 Reply Last reply
    0
    • M Mauricio Ritter

      I've created a windows service that as the time passes it start to consume a lot of memory. I'm using a managed zlib library for compression (one published here). I tried to force a garbage collection but it doesn't work. Question is: can I send a restart command to the service from within the service ? Mauricio Ritter - Brazil MSN: mauricioritter(atsign)hotmail.com
      English is not my native language so, if you find any spelling erros in my posts, please let me know.

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      No you can't. A service doesn't "restart", but first "stops" then "starts". This will kill your service, but it won't start back up again because your code has been stopped. A MUCH better method would be to find out why your code is leaking and fix it, instead of taking the "lazy" way out and ignoring it. 99% of the time, you're not releasing unmanaged resources, by calling .Dispose on your objects or because you forgot to call an unmanged function of your component that tells it to released its unmanaged resources. Either that, or you're using a buggy, unmanaged components. The garbage collector will collect and free managed resources only. It can't do anything about unmanaged resources allocated by unmanaged components, even if those components are wrapped in managed code. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      M 1 Reply Last reply
      0
      • D Dave Kreskowiak

        No you can't. A service doesn't "restart", but first "stops" then "starts". This will kill your service, but it won't start back up again because your code has been stopped. A MUCH better method would be to find out why your code is leaking and fix it, instead of taking the "lazy" way out and ignoring it. 99% of the time, you're not releasing unmanaged resources, by calling .Dispose on your objects or because you forgot to call an unmanged function of your component that tells it to released its unmanaged resources. Either that, or you're using a buggy, unmanaged components. The garbage collector will collect and free managed resources only. It can't do anything about unmanaged resources allocated by unmanaged components, even if those components are wrapped in managed code. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        M Offline
        M Offline
        Mauricio Ritter
        wrote on last edited by
        #3

        Is there anyway that I can isolate my unmanaged call ? I tryed to use appdomains but it didn't work... Mauricio Ritter - Brazil MSN: mauricioritter(atsign)hotmail.com
        English is not my native language so, if you find any spelling erros in my posts, please let me know.

        D A 2 Replies Last reply
        0
        • M Mauricio Ritter

          Is there anyway that I can isolate my unmanaged call ? I tryed to use appdomains but it didn't work... Mauricio Ritter - Brazil MSN: mauricioritter(atsign)hotmail.com
          English is not my native language so, if you find any spelling erros in my posts, please let me know.

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          That is still no solution for leaky code. There is just no excuse for leaving a leak in there like that. You have to go over the calls you're making to the unmanaged library and make ABSOLUTELY SURE, without a shadow of a doubt, that you're properly releasing those unmanaged resources. The documentation on the library your using will most likely help with that. You said your using a library downloaded from CodeProject. Post a message in the aritcle's forum that you downloaded the library from. Maybe there's a known bug and a fix for your problem there. Check with the auther and ask where the underlying unmanaged code came from and if there any doc's on it. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          1 Reply Last reply
          0
          • M Mauricio Ritter

            Is there anyway that I can isolate my unmanaged call ? I tryed to use appdomains but it didn't work... Mauricio Ritter - Brazil MSN: mauricioritter(atsign)hotmail.com
            English is not my native language so, if you find any spelling erros in my posts, please let me know.

            A Offline
            A Offline
            Alex Korchemniy
            wrote on last edited by
            #5

            About leaky code... I suggest you get yourself a profiler. True lifesaver. There are bugs that are nearly impossible to find without one. Try the one from SciTech... memprofiler.com[^]. They also have a great tutorial on the website. Alex Korchemniy

            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