Question

I have a WinForms app that is relying on several libraries over which I have limited control, such as Forms.Images and Forms.WebBrowser. Sporadic sudden memory leaks cause my application to crash. These are not over-time memory leaks that build up. They are random, often different COM exceptions and are impossible to predict -- sometimes they happen after one hour, sometimes after a day.

My current methodology to at least temporarily cope with the problem is to have another application verify that the first one is running by using GetProcessesByName(). However, this is problematic because the ongoing process sometimes crashes but does not close. I just get a WER message (despite the fact that WER is turned off on the computer). What's worse is that when the first process crashes and the memory leak builds up, the second process-checking application ALSO crashes. And then nothing works until I manually reboot the whole shabang.

1) Does anybody know an effective way to have Process A check if Process B is running without having Process A subjected to the memory problems that made Process B crash?

2) If the above is not possible, or too difficult, does anybody know any good third-party tools that can be used to ensure that processes are running without any outstanding WER errors, that restart processes if WER faults are detected, and that can withstand maxed out RAM?

Thanks!

Was it helpful?

Solution

Instead of trying to work around the problem, you should try to fix it first.

If you are expection memory leaks while using unmanaged resources, i'd say instead of ignoring those exceptions thrown by you com components, catch, then dispose and reinitialize if it's not possible possible to figure whats's causing them.

Beside that, it seems your process didn't crash, but rather is not responsive anymore. See Process.Responding. Or monitor memory usage and kill it when it exceeds an given limit Process.WorkingSet64

OTHER TIPS

normally I would use pskill to kill the process from command line. Not much need to write a .net service to do it.

however the fact that your presumably small and simple process check app is failing over would lead me to believe that there's something wrong with the actual system in question.

pslist & pskll

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top