What's gone wrong in my code?

delphi package - automated exception handling
Post Reply
mj
Posts: 13
Joined: Wed Sep 15, 2004 8:00 pm

What's gone wrong in my code?

Post by mj »

I have a multi-threaded application. It works fine for a month, and then stops responding to web requests. It is chewing 100% of a processor.

I need to know what it is doing when this happens. I know that madExcept can, when an exception occurs, dump the stack of all threads. How can I initiate this "manually" please?

I can probably work out a way to recognise the required situation, and other threads appear to be functioning, so I can tell one to do this from an external source. But I need to see "inside" to find out what is causing this, and where it is stuck. I hope you can help!

Probably worth saying that the ideal would be "non-destructive" but if it kills things, so be it. I have to restart the service anyway.
mj
Posts: 13
Joined: Wed Sep 15, 2004 8:00 pm

Re: What's gone wrong in my code?

Post by mj »

Okay, funny how things are so simple once you ask someone else! I realised that the stack dump occurs whenever there is an Exception, and I call HandleException. Err, so why not just generate an exception myself, handle it, and see what happens? And of course, doing that gets me exactly what I want. So I can now create a file called crashdump.txt in a specific location, and the maintenance thread will spot it, rename it, and raise an Exception. Job done!

Thank you, marvellous madExcept. Worth its weight in gold.
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Re: What's gone wrong in my code?

Post by madshi »

FWIW, you could also run the tool "madTraceProcess.exe" in the moment when the CPU runs at 100%.
mj
Posts: 13
Joined: Wed Sep 15, 2004 8:00 pm

Re: What's gone wrong in my code?

Post by mj »

Wow! I am amazed. I never knew that was there, and it isn't mentioned in the documentation pages. I figured it would have a problem with running on my server or something like debug rights, but it "just works". Goodness me, that's clever.
madshi
Site Admin
Posts: 10749
Joined: Sun Mar 21, 2004 5:25 pm

Re: What's gone wrong in my code?

Post by madshi »

8)
Post Reply