1

The situation is this: I run a matlab program that uses a huge amounts of memory and swap memory, however, while it's running, I killed it(ctrl+z), but I find that it did not return the memory it takes. When I want to run the program again, matlab tells me 'out of memory'.
So I need the free the wasteful memory myself, I tried

sudo sysctl -w vm.drop_caches=3

But it doesn't work, the memory is still in use. This is what my top shows

top - 19:39:52 up  1:25,  3 users,  load average: 0.27, 0.51, 0.73
Tasks: 227 total,   1 running, 223 sleeping,   2 stopped,   1 zombie
Cpu(s):  4.2%us,  0.9%sy,  0.0%ni, 94.8%id,  0.1%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   8045612k total,  6878404k used,  1167208k free,    25096k buffers
Swap: 15622140k total,  7239720k used,  8382420k free,   406024k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
 2542 txh18     20   0  457m  18m  10m S   10  0.2   6:24.66 gnome-system-mo    
 1403 root      20   0  201m  14m 4356 S    6  0.2   3:33.67 Xorg               
 2218 txh18     20   0 1272m  39m  10m S    2  0.5   1:51.68 compiz             
 8176 txh18     20   0  884m  62m  22m S    2  0.8   0:08.86 chromium-browse    
 7858 txh18     20   0 2858m 143m  53m S    1  1.8   0:25.54 chromium-browse    
 2547 txh18     20   0  503m 9.9m 4796 S    1  0.1   0:04.91 gnome-terminal     
 8298 txh18     20   0  483m  49m  24m S    1  0.6   0:03.39 chromium-browse    
   15 root      RT   0     0    0    0 S    0  0.0   0:00.01 watchdog/2         
 2188 txh18     20   0 19556 2608  612 S    0  0.0   0:06.88 dbus-daemon        
 2289 txh18     20   0  316m 9176 6168 S    0  0.1   0:01.26 gtk-window-deco    
 2299 txh18     20   0  511m  15m 5544 S    0  0.2   0:16.61 unity-panel-ser    

Hope someone can help me free my memory, thanks.
I'm sorry, the top list is not complete, when I shift+M in the top, I found that the MATLAB process is still there.

5
  • 2
    Your problem is described entirely in terms of conclusions rather than data or evidence. For example, you say "it did not return the memory it takes". First, there's no way to understand what this is actually claiming. Is it about virtual memory? Physical memory? But second, we don't know what evidence led you to that (likely incorrect) conclusion, so we can't figure out what's going on. Jul 5, 2013 at 11:43
  • Reboot your machine ;-)
    – doctorlove
    Jul 5, 2013 at 11:44
  • And, by the way, dropping caches is pointless. The system will drop caches if it needs to by itself, so all you're doing is dropping caches even if they don't need to be dropped, which just hurts performance. Jul 5, 2013 at 11:44
  • Yeah, that's what I do, what I want to know the reason.@doctorlove
    – cloudyFan
    Jul 5, 2013 at 11:50
  • As it's both offtopic and solved, just delete this question please.
    – fvu
    Jul 5, 2013 at 12:00

1 Answer 1

10

Ctrl-Z doesn't kill the process. It sends the SIGTSTP signal to the process. You can even resume the thus killed process by saying fg.

If you want to kill the process, you probably want SIGKILL or SIGINT (Ctrl-C).

3
  • Nice catch, but in his top listing there's no process called matlab. If he actually ctrl-z'd it, it would still hang around in memory.
    – fvu
    Jul 5, 2013 at 11:48
  • 3
    @fvu His process listing is neither complete, nor is sorted by memory.
    – devnull
    Jul 5, 2013 at 11:49
  • you are right! I didn't shift+M in the top, now I found the MATLAB is still there!@devnull
    – cloudyFan
    Jul 5, 2013 at 11:53

You must log in to answer this question.