33

I'm using Ubuntu 12.10 with Gnome-Classic. I am getting this error frequently and with almost all programs, big and small. When I try to open them, they don't start, and instead I get an error message that says Could not launch 'Program' - Failed to fork child process (Cannot allocate memory). This wasn't a problem until within the last few weeks.

cannot allocate memory

I can not discern any commonality among the programs that cause this error. It seems to be more a matter of time. After my computer has been running for a while, anywhere from a day to a few days, then I can't seem to start any new programs.

The only way I know to prevent this error is to reboot the computer.

Why am I getting this error and what do I do to stop it happening?


I ran the memtest available from the GRUB menu, and it reports no errors, so I don't think this is a hardware failure.

I also ran sudo apt-get check, and no errors were found.

Here is some requested command line output:

$ free -m
             total       used       free     shared    buffers     cached
Mem:          3945       3753        191          0        181        475
-/+ buffers/cache:       3096        848
Swap:         3813         60       3753

$ swapon -s
Filename                Type        Size    Used    Priority
/dev/sda6                               partition   3905532 61648   -1

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 31421
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 31421
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

This is the output of ps --sort -rss -eo rss,pid,command | head after the error starts showing up:

$ ps --sort -rss -eo rss,pid,command | head
  RSS   PID COMMAND
1963400 2953 gnome-panel
155496 4029 banshee /usr/lib/banshee/Banshee.exe --redirect-log --play-enqueued
104944 15765 /opt/google/chrome/chrome --type=renderer --lang=en-US --force-fieldtrials=ForceCompositingMode/disable/GlobalSdch/global_enable_sdch/InfiniteCache/No/OmniboxDisallowInlineHQP/Standard/OmniboxHUPCreateShorterMatch/Standard/OmniboxHUPCullRedirects/Standard/OmniboxSearchSuggestTrialStarted2012Q4/2/OneClickSignIn/Standard/Prerender/PrerenderEnabled/SBInterstitial/V2/SpdyCwnd/cwndMin10/SpeculativePrefetching/Disabled/Test0PercentDefault/group_01/UMA-Dynamic-Binary-Uniformity-Trial/default/UMA-Session-Randomized-Uniformity-Trial-5-Percent/default/UMA-Uniformity-Trial-1-Percent/group_09/UMA-Uniformity-Trial-10-Percent/group_08/UMA-Uniformity-Trial-20-Percent/group_03/UMA-Uniformity-Trial-5-Percent/group_06/UMA-Uniformity-Trial-50-Percent/group_01/WarmSocketImpact/last_accessed_socket/ --enable-crash-reporter=ECE9000094D279FD3B14B35A74BF72CC,Ubuntu 12.10 --renderer-print-preview --disable-accelerated-2d-canvas --disable-accelerated-video-decode --channel=15654.5.89177240
78164 15654 /opt/google/chrome/chrome       
74912 19890 /usr/bin/python /usr/share/oneconf/oneconf-service
65476 12419 /usr/bin/perl /usr/bin/shutter
61096 19626 /usr/bin/python3.2 /usr/sbin/aptd
57832 15708 /opt/google/chrome/chrome --type=renderer --lang=en-US --force-fieldtrials=ForceCompositingMode/disable/GlobalSdch/global_enable_sdch/InfiniteCache/No/OmniboxDisallowInlineHQP/Standard/OmniboxHUPCreateShorterMatch/Standard/OmniboxHUPCullRedirects/Standard/OmniboxSearchSuggestTrialStarted2012Q4/2/OneClickSignIn/Standard/Prerender/PrerenderEnabled/SBInterstitial/V2/SpdyCwnd/cwndMin10/SpeculativePrefetching/Disabled/Test0PercentDefault/group_01/UMA-Dynamic-Binary-Uniformity-Trial/default/UMA-Session-Randomized-Uniformity-Trial-5-Percent/default/UMA-Uniformity-Trial-1-Percent/group_09/UMA-Uniformity-Trial-10-Percent/group_08/UMA-Uniformity-Trial-20-Percent/group_03/UMA-Uniformity-Trial-5-Percent/group_06/UMA-Uniformity-Trial-50-Percent/group_01/WarmSocketImpact/last_accessed_socket/ --enable-crash-reporter=ECE9000094D279FD3B14B35A74BF72CC,Ubuntu 12.10 --extension-process --renderer-print-preview --disable-accelerated-2d-canvas --disable-accelerated-video-decode --channel=15654.2.1555888673
42108  3030 /var/lib/dropbox/.dropbox-dist/dropbox

Based on suggestions in the comments and answers, it seems possible the problem is with the Gnome Panel or its applets. Here are the applets I have running:

Panel applets

The applets are Indicator Applet 12.10.1, System Monitor 3.5.92, and a "notification Area". and "date and time", neither of which I can access the version number for.

Here is some more requested command line output:

$ df -h
Filesystem                             Size  Used Avail Use% Mounted on
/dev/sda5                               19G   12G  6.4G  64% /
udev                                   2.0G  4.0K  2.0G   1% /dev
tmpfs                                  790M  1.1M  789M   1% /run
none                                   5.0M     0  5.0M   0% /run/lock
none                                   2.0G   84K  2.0G   1% /run/shm
none                                   100M     0  100M   0% /run/user
/dev/sda7                              384G  306G   59G  84% /home
mythbuntu@192.168.0.4:/home/mythbuntu  437G  360G   55G  87% /home/dave/Mythbuntu
$ sudo du -csh /var/log
15M /var/log
15M total
Anwar
  • 75,875
  • 31
  • 191
  • 309
Questioner
  • 6,729
  • 33
  • 106
  • 165
  • Ok, I've appended my answer below with some "next-steps". – Leland Kristie Feb 11 '13 at 18:53
  • How long did you run `memtest`? Errors often show up in the later tests only. – guntbert Feb 15 '13 at 18:16
  • @guntbert: I let `memtest` run until there was a message at the bottom of the screen that said all tests were complete. – Questioner Feb 16 '13 at 04:06
  • Ok, I've appended my answer below once again with some "next-steps". – Leland Kristie Feb 16 '13 at 19:25
  • You didn't mention what version of Ubuntu? – Alistair Buxton Feb 17 '13 at 02:40
  • @AlistairBuxton: 12.10 with Gnome-Classic. I've updated the question with that information. – Questioner Feb 17 '13 at 04:01
  • Are you using any non-default applets? Also, how often do you update? Last change on gnome-panel was 4 months ago. – Alistair Buxton Feb 17 '13 at 04:30
  • Although it looks like gnome-panel has allocated an unusual amount of memory, I don't think this is the direct cause of the problem - you still have plenty of swap free and even some memory used for cache. Some other resource must be exhausted, and the high memory use is just the memory used by allocating that resource. Most likely too many open files or too many child processes. Could also be a full disk caused by out of control error logging. – Alistair Buxton Feb 17 '13 at 08:29
  • @AlistairBuxton: Thanks for your comments. As far as I know, I have the latest updates for everything. I check for updates nightly. Other than that, I'm open to the other suggestions you offer, but I wouldn't know how to narrow any of them down, so if you have any specific suggestions on how to proceed, that would be helpful. – Questioner Feb 17 '13 at 08:54
  • @AlistairBuxton: Additional note, I don't know what a "non-deafult applet" would be. What I have is `Indicator Applet Session 12.10.1`, a date and time (I think it's default, it doesn't seem to have an "About" option), `Indicator Applet 12.10.1`, `System Monitor 3.5.92`, and a "notification Area", which also doesn't have an "About" option, so I don't know its version. – Questioner Feb 17 '13 at 09:22
  • @DaveMG `df -h` from a shell prompt will return disk-usage statistics so you can verify none of the disk partitions are at, or close to, 100% usage. – Leland Kristie Feb 17 '13 at 17:11
  • @DaveMG: `sudo du -csh /var/log` from a shell prompt will return the size of the `/var/log` folder. – Leland Kristie Feb 17 '13 at 17:25
  • System monitor is non-standard, in that it isn't on the panel by default. I couldn't reproduce any memory leak with a standard setup so I will focus on that. – Alistair Buxton Feb 17 '13 at 19:52
  • @AlistairBuxton: I've added the command line output for the latest commands you've requested. Also, I've removed the `System Monitor Applet` from my panel, but after doing so, my memory usage did not drop at all. I know that's not conclusive proof of anything, but I'm a little skeptical that the `System Monitor Applet` is the problem. I can always be proved wrong, though. – Questioner Feb 18 '13 at 02:43
  • I think you are right that system monitor is not the problem. I have left it running on max refresh speed overnight and not seen any increase in memory usage. I see you have indicator-weather installed. For me that applet is very buggy indeed. It crashes several times per day here. Also note that there can be logs in your homedir eg ~/.xsession-errors (which would be worth looking at, along with dmesg, when the problem happens again.) – Alistair Buxton Feb 18 '13 at 09:59
  • @AlistairBuxton: The memory errors haven't happened yet, but currently in `~/xsession-errors` there is only one line, repeated over and over countless times: `(update-manager:5647): Gtk-WARNING **: /build/buildd/gtk+3.0-3.4.2/./gtk/gtkliststore.c:851: Unable to convert from glong to gint`. Also, the weather icon is bound to the time and date applet. Are you saying the time and date app is buggy? – Questioner Feb 18 '13 at 10:18
  • @AlistairBuxton: I now think there is reason to believe that the problem is with the date/time/weather applet. I tried removing it from the panel, but it stayed there. So then I restarted the panel with `killall gnome-panel`, and the date/time/weather applet was gone, and the memory dropped right down from near 90% to 20%, which seems more normal. – Questioner Feb 18 '13 at 15:49
  • Killing the panel will for sure free up the memory no matter what was causing it. Weather applet is high on the list of suspects. xsesion-errors also suggests a problem with update-manager (perhaps it's indicator icon). The weather isn't really part of the same applet as the other stuff, it's just that all indicators are grouped into a single indicator-applet. It sounds like you've removed that - you probably want it back at some point. This is a good way to test anyway. If the problem stops happening we've narrowed it down to an indicator at least. – Alistair Buxton Feb 19 '13 at 00:28
  • @AlistairBuxton: Thanks for your continued help. 1) The update-manager never has an icon in my Gnome Panel. When it alerts me of updates, I see it in my Cairo Dock. 2) In the 12 hours since I have removed the weather/date/time, the memory has not increased much at all. Also, I just tried restarting Gnome Panel to see what effect that would have, and there was no change in memory (according to System Monitor). From here I will put the time/weather/date back in and see if the memory leak starts again. Also, please note I'm not using the app indicator "complete", as it had different problems. – Questioner Feb 19 '13 at 03:19
  • 1
    @AlistairBuxton: Hmmm... after seven hours, with the time/date applet back on the panel, there seems to be no increase in memory. However, one thing that's different is there is no weather display. In the time/date applet, there is an option to display weather, but even though I have it selected, no weather icon appears. Which seems odd, and might confirm the problem is specifically related to the weather functions within the time/date/weather app. – Questioner Feb 19 '13 at 10:24

4 Answers4

37

Some process is leaking memory. To get an idea of which process this might be, run

ps --sort -rss -eo rss,pid,command | head
jdthood
  • 12,287
  • 2
  • 48
  • 66
  • I've added the output to the command to my question. I captured this output after I started getting the error. – Questioner Feb 15 '13 at 01:45
  • Most probably the problem lies with one of the less frequently used indicators you are using, e.g., either the one on the left that looks like a circular saw blade, or the weather indicator. Remove each of these in turn to see if that fixes the problem. – jdthood Feb 20 '13 at 08:19
  • Turns out it was the weather indicator. See the OP's own answer. – jdthood Feb 20 '13 at 12:01
  • Interesting - I think that was the problem on my linux system too. I noticed some gnome-daemon thingy constantly being respawned. – shevy Jun 26 '20 at 12:50
19

I suggest you start the troubleshooting process by testing the RAM with the built-in utility provided in the GRUB boot menu and eliminate "bad RAM" as a source of the problem.

Memory test Memory test

Memtest86+ Memtest86+

Next, check your system for broken dependencies from a terminal with sudo apt-get check and, if errors are found, rerun the command as sudo apt-get check -f to try and correct them.

If you please, try these steps and report back here with any results.

Leland


Hi Dave,

Ok then - we've ruled out the hardware as a source of the problem.

Next, let's examine memory usage and process settings on your computer; run these commands from a terminal prompt:

Display amount of free and used memory

free -m

Display swap usage summary

swapon -s

Display user-process resource limits

ulimit -a

The screenshot below is from a clean installation of 10.04LTS. The particulars to note from the first and second yellow-circled items are in the "used" column, which display memory and swap space available for the operating system to use, i.e., they're not all used up.

The bottom yellow-circled item displays no limits on the number of user-processes, i.e. gFTP or other application for example, that the operating system will permit the user to run.

If you please, try these steps and report back here with any results.

Leland

Memory usage and process resource limits


Hi Dave,

The results returned from ps --sort -rss -eo rss,pid,command | head you have posted show the gnome-panel process using roughly 1.8GB of memory which seems a little unusual - that seems like a lot of memory for the Desktop Environment to be using.

You can get a breakdown of the memory the gnome-panel process is using by running the circled commands in the screenshot below and see where it's all going - that may reveal something that stands out.

For comparison, the gnome-panel process on my virtual machine is using 48MB of RAM - granted though, the 10.04 machine in these screenshots is a virtual machine I'm using for tests only and not my own desktop.

pmap from gnome-panel process

Given that, I'll put forward the next step is to isolate the problem to "something" in the Gnome desktop environment.

To test this, try installing the KDE plasma workspace which you'll find in the Ubuntu Software Centre.

kde-plasma desktop environment

Once it's installed, reboot your computer and login with a KDE session instead of Gnome, run your applications as best you can (the desktop is completely different) to see if the "Cannot allocate memory" error repeats itself here.

Simply to be clear, you'll be able to run the same CLI "tests" in a KDE environment as we've done in the Gnome environment and be able to compare results in examining the computer's behaviour between the two.

In KDE, the console application you'll be looking for is xterm which you can find from the Search dialog on the main menu.

xterm pid and pmap for plasma-desktop

I'm going to throw in a little confidence here and say I think we're collectively on the right track to isolating the problem.

Leland

Leland Kristie
  • 411
  • 2
  • 5
  • Thank you for responding. I ran both the memtest and the `apt-get` commands you suggested, and both reported no errors. I have updated my question accordingly. – Questioner Feb 11 '13 at 01:08
  • I've appended to my question the output of the commands you requested. The only thing I note is that under `max user processes` it does not say `unlimited` as yours does. Mine has the number `31421`. – Questioner Feb 12 '13 at 01:16
  • 1
    Hi Dave, A short note to let you know that I'll be able to follow-up again with you by the weekend. My day job keeps me busy into the evenings and so I thought I'd simply drop a courtesy note to you here to let you know I haven't disappeared. Leland – Leland Kristie Feb 14 '13 at 00:05
  • Oh and by the way, I tried changing the max user processes setting all the way down to 1024 and wasn't able to reproduce the error this way...thought I'd mention I tried that. – Leland Kristie Feb 16 '13 at 19:56
  • I have installed the KDE desktop, but I'm currently waiting until I start seeing the error again, and then I will run the `pmap` command and post that output here. I've also done a little searching and have found there are some mentions of memory leaks in gnome-panel, so that seems a likely suspect. – Questioner Feb 17 '13 at 09:14
  • Hi Dave, Ok, good shot - let's see how that goes. Leland – Leland Kristie Feb 17 '13 at 17:06
  • Just an update. According to `uptime`, my computer has been running for 1 day and 6 hours. The current memory usage, not including swap, is 65% (2.5 of 3.9 GB) and increasing at a rate of a tenth of a percent every few minutes. So I expect to start seeing the error coming up later tonight or tomorrow morning my time. – Questioner Feb 18 '13 at 02:52
  • Another update: I think the problem could be with the date/time/weather applet. I removed it from my gnome panel, and the memory seems to have dropped down to normal levels. – Questioner Feb 18 '13 at 15:52
4

After experimenting with having it on and off over the last couple of days, I'm confident in now saying that the problem was a memory leak in the weather indicator portion of the time and date applet. When the weather is displaying, the memory usage increases over time. When the weather is not displaying the memory does not increase.

I guess this is a bug with the weather indicator that should be reported, but reporting bugs on Launchpad is far too convoluted a process for me to undertake.

Questioner
  • 6,729
  • 33
  • 106
  • 165
  • Open a terminal on your machine and run "apport-bug" which will solicit information and file the bug report for you. – jdthood Feb 20 '13 at 10:49
  • 2
    @jdthood: That's the theory of how easy it should be. The reality is that the first screen of options doesn't describe my problem, and the "other" option just tells me I need a package name and then quits. Similar to [this](http://askubuntu.com/q/255911/17041). – Questioner Feb 20 '13 at 12:02
  • Open https://bugs.launchpad.net/ubuntu/+source/indicator-weather in a browser, click on "Report a bug" and follow the directions. Once you know the number assigned to the report, run "apport-collect " to upload relevant information about the affected machine. – jdthood Feb 20 '13 at 13:12
1

If you're having this issue using Ruby on Rails with Digital Ocean it's likely because you have too little RAM. Try upping the RAM from 512MB to 1GB, that fixed it for me.

Glenn Dayton
  • 153
  • 1
  • 6