I’m calling a finite element analysis program from within a statistics program, to evaluate a possible design. The statistics program generates designs, starts the FEM program, waits for it to terminate, collects the file it wrote, pulls all the numbers together into one record, then generates another design and does it all over again. I can search for sweet spots this way.
The problem is that after a few hundred design evaluations my PC starts running the disk drive constantly, complaining about insufficient memory and trying to increase the pagefile. If I quit all the “applications” listed in the Task Manager, paging continues. If I then shut the system down, it lists a process being run by the FEM program that won’t terminate normially which I must End Now.
I’m posting questions on the FEM user’s site that are specific to that software, but I’m not sure I should be blaming it. What can anybody tell me about chasing down things like memory leaks, lost processes and the like?
The Applications list doesn’t tell you much, really. Click on the ‘Processes’ tab, and sort by RAM useage. Chances are there’s something related to your FEM program running there. You can also kill things more effectively through that tab.
I’d bet on some background thread leaking RAM; if you kill it you should get it back and not have to restart your whole PC.
>I’d bet on some background thread leaking RAM; if you kill it you should get it back and not have to restart your whole PC.
Thanks - glad your bet is similar to what I was thinking.
Not having to restart is nice, I guess, but is there something more automatic I can do? More specifically, can I pass a phrase to the OS that will seek out and kill the problem process? Maybe I can do this after every invocation of the FEM, or every 10 invocations, or something. I remember doing something like this in UNIX, piping something through grep to kill whatever process had a name partly matching the name of the problematic program. But I’m using WinXP now.
Sounds to this amateur like that would merely delay the inevitable, by giving more room for it to grow until it again runs out of memory. I know nothing about how memory leaks happen, but that sounds like a better approach.
Here’s another idea: Does it poop out at around the same place every time? And even if you make extra room for it? If so, then maybe there’s a design flaw in your program. Make sure that whatever should get reinitialized on each iteration really does get reinitialized on each iteration. If there’s a bug that allows something to keep on growing, that would cause this sort of behavior. Don’t just look at your code and say “Yeah, it’s okay”, but actually check lengths and sizes and stuff. You could have a 100-gigabyte-long string and not realize it.
engineer_comp_geek, I am using your suggestion with some success. I keep checking to see if the called app, which is called FlexPDE519.exe, has dropped a file called summary_export.txt or if ten minutes has elapsed. If either of these things is true I send this message to the OS:
I then wait a few seconds and move on. I have tried both methods to see if some child process is the problem.
Sometimes, though, using either command, it still dies. My Task Manager shows a process called FlexPDE519.exe is still running. I can open a “Run” window from Start and type the command in there, and Task Manager still shows FlexPDE519.exe running. So, for some reason, this works sometimes and doesn’t work other times. Though, selecting the process in Task Manager and clicking on Kill Process does work (though of course I can’t use that method programatically).
Any ideas?
In re other suggestions, I can’t defrag my disk drive inside a program loop, and I can’t dismantle the called application, which is a major proprietary piece of software. Running the same script will crash it sometimes and not other times. I think I have to find a solution more or less like engineer_comp_geek offers.
I should have mentioned, FWIW, when my calling app sends the message to the OS, I see a console window titled “C:\WINDOWS\system32 askkill.exe” and containing the single line “Loading the tasks information …” flash on the screen for what couldn’t have been 100 ms. It was damn hard to get a look at this by clicking a Send button and the PrintScreen key in rapid succession, it took about 30 tries. Clearly, the message is getting sent, and sometimes doesn’t work this way or in the Run command.
Also, the taskkill command does work in some circumstances. I haven’t noticed any difference between the circumstances in which it does work and those in which it doesn’t.
Checking carefully character by character, the process name I supply and the process name as it appears in Task Manager appear identical.
How much memory does your PC have? No matter how interesting tracking down the issue may be, it may be more cost-effective to simply put in sufficient memory that there is no longer a problem.
I have 2 GB, but the app is swelling to ten times normal size when this happens. I think something’s gone way wrong that just makes it ask for memory endlessly.
And sometimes it’s another kind of failure, displaying an error dialog and waiting for me to answer, without the memory overrun. The problem is evolving as we speak. But if taskkill worked it would eliminate both kinds of problems.
Eep! Do you have any maintenance contract with the authors? Also, I notice you’re using the latest version of the software (5.0.19): have you tried reverting to a previous version?
Try the /F option with taskkill. This forces the task to exit. If you don’t use the /F option, then windows asks the task to exit. If the task chooses not to exit for some reason (like it’s stuck somewhere) then it won’t exit.
>Eep! Do you have any maintenance contract with the authors? Also, I notice you’re using the latest version of the software (5.0.19): have you tried reverting to a previous version?
I’ve got a great relationship with the author. In fact one of the features of the software was my suggestion. I keep icons for about 6 versions of the software on my desktop typically, and have tried two other versions with this problem. It is amazing that he can get this product to do so much and be so versatile under Windows, and it sells at an amazing low price too. I’m a huge fan. I can accept needing to be adept with various errors, given that I am often doing weird things with the product. When Windows Explorer crashes, that’s when I get disdainful.
Getting that app not to stop is one angle to work. But I often call one app from another in doing parametric studies, and want to be better at doing it, whether I have control over both apps’ behavior or not.
>Try the /F option with taskkill.
Ahah! Now, see, this is what I mean by being better at calling one app from another. Don’t know why I didn’t find this for myself, but e_c_g you may have just boosted me a nice little step along my path! Thanks^3!