For Programmers: Free Programming Magazines  


Home > Archive > C# > April 2006 > C# Service locks-up (Memory/Resource Management/GC Problem?)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author C# Service locks-up (Memory/Resource Management/GC Problem?)
Keep it to Usenet please

2006-04-14, 7:04 pm

I've inherited a service written in C# that will eventually become
non-responsive (Has to be "Force Quit" -- can't be stopped/restarted
from the Services Control Panel.). It really seems like what would be
a problem with Memory/Resource Management in C++ -- memory not being
freed, files not being closed, etc.. If this was C/C++, I'd use one
of the tried and trued malloc wrappers, custom
constructors/destructors, etc..

Other than a source code crawl to look for things that need to be
explicitly .Dispose()ed, is there a better way to track something like
this down?

--
A: No. See: Help, I'm
<http://www.netmeister.org/news/learn2quote.html> being held
<http://www.greenend.org.uk/rjk/2000/06/14/quoting> in a .sig
Q: Should I include quotations after my reply? factory!
William Stacey [MVP]

2006-04-16, 10:02 pm

Have you ruled out an actual deadlock (Monitor) issue. May be able to see
where the hang is with Managed Stack Explorer:
http://go.microsoft.com/fwlink/?LinkId=59380

--
William Stacey [MVP]

"Keep it to Usenet please" <idontreadthis56@hotmail.com> wrote in message
news:idontreadthis56-A0E036.15262014042006@netnews.asp.att.net...
| I've inherited a service written in C# that will eventually become
| non-responsive (Has to be "Force Quit" -- can't be stopped/restarted
| from the Services Control Panel.). It really seems like what would be
| a problem with Memory/Resource Management in C++ -- memory not being
| freed, files not being closed, etc.. If this was C/C++, I'd use one
| of the tried and trued malloc wrappers, custom
| constructors/destructors, etc..
|
| Other than a source code crawl to look for things that need to be
| explicitly .Dispose()ed, is there a better way to track something like
| this down?
|
| --
| A: No. See:
Help, I'm
| <http://www.netmeister.org/news/learn2quote.html> being
held
| <http://www.greenend.org.uk/rjk/2000/06/14/quoting> in a
..sig
| Q: Should I include quotations after my reply?
factory!


greg.merideth@gmail.com

2006-04-16, 10:02 pm

While not a killer tool (for this use) I use the sys internals process
explorer to watch thread creation from within my c# services. Using PE
you can kill off individual threads from within your service to help
pin down issues.

Keep it to Usenet please

2006-04-17, 7:02 pm

In article <uB3Lo1cYGHA.3868@TK2MSFTNGP04.phx.gbl>,
"William Stacey [MVP]" <william.stacey@gmail.com> wrote:

> Have you ruled out an actual deadlock (Monitor) issue. May be able to see
> where the hang is with Managed Stack Explorer:
> http://go.microsoft.com/fwlink/?LinkId=59380


Unfortunately, this app is still .NET 1.1. Looking into migrating to
2.0 is one of the other tasks on my list, but they want the hanging
tracked down first.

--
A: No. See: Help, I'm
<http://www.netmeister.org/news/learn2quote.html> being held
<http://www.greenend.org.uk/rjk/2000/06/14/quoting> in a .sig
Q: Should I include quotations after my reply? factory!
William Stacey [MVP]

2006-04-17, 7:02 pm

1) Maybe you could attach to it using VS debugger and use a debug build on
the service.

2) Managed Debug Assistants may be another tool.

3) If it is using an Monitors (i.e. lock()), then find them all and replace
any "forever" wait locks with timeouts, then throw exceptions on timeout so
you can find the offending code.

4) Have not tested it, but does just throwing an exception in a service
produce the same effect? Maybe need some more try/catch logic and logging.

5) Maybe Windbg and SOS:
http://msdn.microsoft.com/msdnmag/i...3/06/Bugslayer/

6) Compile with 2.0. I understand you want to fix it in 1.1 first, but with
the updates and fixes in 2.0, you may find the issue with a simple compile
error and/or find the issue faster because your using the 2.0 runtime and
you might see different behavior that help you nail the issue. Use it as
more of a debug tool, then as a comittment to move to 2.0. Now you can also
use Managed Stack Explorer as a bonus! You got to do something, so this
would be my first pick as it helps elliminate a lot of variables up front
with minor effort. Also, during debugging, leave as a Console app instead
of a service - just easier to debug and test. Use existing stress tests to
see if you can get it to fail in lab. If not, develop some more tests.

--
William Stacey [MVP]

"Keep it to Usenet please" <idontreadthis56@hotmail.com> wrote in message
news:idontreadthis56-CFC637.10565317042006@netnews.asp.att.net...
| In article <uB3Lo1cYGHA.3868@TK2MSFTNGP04.phx.gbl>,
| "William Stacey [MVP]" <william.stacey@gmail.com> wrote:
|
| > Have you ruled out an actual deadlock (Monitor) issue. May be able to
see
| > where the hang is with Managed Stack Explorer:
| > http://go.microsoft.com/fwlink/?LinkId=59380
|
| Unfortunately, this app is still .NET 1.1. Looking into migrating to
| 2.0 is one of the other tasks on my list, but they want the hanging
| tracked down first.
|
| --
| A: No. See:
Help, I'm
| <http://www.netmeister.org/news/learn2quote.html> being
held
| <http://www.greenend.org.uk/rjk/2000/06/14/quoting> in a
..sig
| Q: Should I include quotations after my reply?
factory!


Keep it to Usenet please

2006-04-18, 7:03 pm

In article <eQAdiBkYGHA.3328@TK2MSFTNGP02.phx.gbl>,
"William Stacey [MVP]" <william.stacey@gmail.com> wrote:

> 6) Compile with 2.0. ...


It may be already. It looked like 2.0 wasn't installed, but looking
at "Add/Remove Programs", .NET 2.0 has been installed. I'm not sure
of the best way to determine if the code has been migrated to 2.0 or
not.

--
A: No. See: Help, I'm
<http://www.netmeister.org/news/learn2quote.html> being held
<http://www.greenend.org.uk/rjk/2000/06/14/quoting> in a .sig
Q: Should I include quotations after my reply? factory!
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com