• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

Managing memory allocated to processes

Recently I've had a problem with my linux machine where the disk starts thrashing and it rapidly degenerates into an unresponsive state where the disk is constantly accessing. If I catch it quick enough, I can reboot with ctl-alt-del; otherwise it's the reset button. The symptoms seem to point to a memory leak on a massive scale, where a process is rapidly filling all available real and virtual memory. It seems to be associated with running StarOffice, but I could be wrong.

I have two questions:

1. How can I find out which process is causing this, keeping in mind that once the problem has started it's just a few minutes or seconds until complete system unusability.

2. How can I prevent this from happening? Is there a way to limit the resources resources any single process is allowed to use?

Thanks,
Avdi
0
avdi
Asked:
avdi
1 Solution
 
kiffneyCommented:
To find out what's doing this, you could try to run top as a background process, putting its output to a file.  Something like this:

top -b -n 100 -d 15 >> top.out &

would run top as a background process, writing its output to top.out, for 25 minutes (d 15 means every 15 seconds print the output, and n 100 means do this 100 times - alter this to suit).  Then run staroffice or whatever you suspect and then later you can look at top.out to see what's the hog (look at the percent memory column).

To restrict the bad process, if you use the bash shell it has a ulimit command that you can use when you start the process to restrict its memory use.  'man bash' for the gory details.  I'm not sure it will do you much good since whatever app is sucking all memory will probably crash once it can't get any more.  

0
 
avdiAuthor Commented:
Thank you very much! I particularly like your solution for question 1; others had suggested using top but yours is the only feasible method I have seen.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now