Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Sometimes when i run skype it takes an enormous amount of memory so much in fact
that i can't close it and everything just lags like CRAZY. But this is only sometimes
is there a command that can track skype and when it's taking a HUGE amount of memory kill it. something like this

track skype when memory exceeds XXXX killall skype
share|improve this question
    
If possible, please consider closing some of your other open questions by selecting the best answer (if they have one). Consider which answers have been useful and need an upvote. We need users to maintain their questions so that the site can be an effective tool for the next person with your problems. For more details on best practices consider reading the FAQ on asking questions. –  hexafraction Jun 5 '12 at 20:24
1  
There is actually a bug report open for this memory leak. bugs.launchpad.net/ubuntu/+source/skype/+bug/979880 If it affects you, mark it as affecting you so hopefully it gets more attention and will be fixed. –  hexafraction Jun 5 '12 at 20:27
3  
You can limit the virtual memory usage of a shell and its children with ulimit -v XXXX, so if you issue that command and then start skype from that shell then it'll limit the virtual memory usage by skype. –  Samik Jun 5 '12 at 20:59

3 Answers 3

While there could be a point in setting limits proactively, let's answer OP's question :-)

Make an Upstart script in /etc/init/skype-killer.conf. Replace skype with Skype's binary name if its not skype, and replace 500000 (as in 500000 kB = 500 M) with the limit in kB's you wish to enforce for Skype virtual memory size and 30 with the number of seconds between checks.

This job will start on startup and keep running checking for skype memory usage. After you have copied this to /etc/init with sudo, do sudo start skype-killer to get it going, or reboot system. If you wish to revise memory usage, edit the skype-killer.conf and do sudo stop skype-killer; sudo start skype-killer.

start on startup
stop on shutdown

script
  while /bin/true; do
    if $(pidof skype); then
      test $(cat /proc/`pidof skype`/status | grep "VmSize:" | sed -re s,VmSize:\\s+,, | cut -d" " -f1) -gt 500000 && killall skype
    fi
    sleep 30
  done
end script
share|improve this answer
    
super useful script given that upstart's use of "limit rss" is broken, thanks! –  Kevin Mar 3 at 3:53

The simplest way is to use the bash ulimit command, which tells the kernel to automatically kill a shell (and therefore all its child processes) when memory usage exceeds a specific limit.

  • Start a terminal with Ctrl-Alt-T
  • Type ulimit -v N to set the limit in kilobytes e.g. 256000 for 256 MB.
  • Start Skype with skype

The kernel will automatically kill Skype if it exceeds the limit you set via N. You may have to experiment a few times with N values to set an appropriate threshold where Skype is killed just before it begins to affect your system ("hang") and not during normal operation.

share|improve this answer

the code of Tuminoid didn't work for me. I have modified it in the following way. Moreover I have decreased the memory threshold and the sleeping time.

start on startup
stop on shutdown

script
   while /bin/true; do
       if (pidof skype) 
     then
          test $(cat /proc/`pidof skype`/status | grep "VmSize:" | sed -re s,VmSize:\\s+,, | cut -d" " -f1) -gt 500000 && killall skype
       fi
       sleep 10
  done
end script
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.