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