Bug 639732

Summary: Nautilus is leaking memory
Product: Red Hat Enterprise Linux 6 Reporter: William Cohen <wcohen>
Component: gnome-desktopAssignee: Tomáš Bžatek <tbzatek>
Status: CLOSED ERRATA QA Contact: Desktop QE <desktop-qa-list>
Severity: high Docs Contact:
Priority: high    
Version: 6.0CC: alexander, bb, chad.truhn, Colin.Simpson, collura, gauthier.stephane, jcpunk, kai, mfojtik, roysjosh, ryan.stanyan, spoyarek, spurrier, syeghiay, tpelka, tsmetana, vbenes, woodard, wyvern1
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gnome-desktop-2.28.2-9.el6 Doc Type: Bug Fix
Doc Text:
Previously, due to an object not being destroyed, the Nautilus file manager could consume an excessive amount of memory. Consequently, constantly growing resident memory would slow down the system. The source code has been modified to prevent memory leaks from occurring and Nautilus now consumes a reasonable amount of memory.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-03-20 13:56:28 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 756082, 787799    
Attachments:
Description Flags
Memory map of the problem nautilus
none
script to watch for mallocs by nautilus none

Description William Cohen 2010-10-03 18:25:36 UTC
Description of problem:

I have RHEL-6 on my laptop running for some time I have noticed the machine getting very slow and the disk on most of the time. When doing a "top" and sorting based on memory "M" I see the following:

$ top

top - 14:06:48 up 3 days,  3:17,  5 users,  load average: 0.59, 2.68, 2.34
Tasks: 240 total,   1 running, 239 sleeping,   0 stopped,   0 zombie
Cpu(s):  3.5%us,  2.0%sy,  0.0%ni, 93.4%id,  1.1%wa,  0.1%hi,  0.0%si,  0.0%st
Mem:   3716868k total,  3181948k used,   534920k free,    29296k buffers
Swap:  5947384k total,  5944632k used,     2752k free,   427132k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
 2954 wcohen    20   0 7657m 1.8g 2680 S  0.3 49.4   5:59.50 nautilus           
 4031 wcohen    20   0  765m 177m  26m S  8.6  4.9   0:19.41 firefox            
 3345 wcohen    20   0  633m  99m  828 S  0.0  2.7   0:25.10 gnome-screensav    
 2514 root      20   0  235m  35m 7944 S  8.3  1.0  78:06.80 Xorg               



Version-Release number of selected component (if applicable):

nautilus-2.28.4-15.el6.x86_64

How reproducible:

Seems to take a while, but I have seen nautilus using a large amount of memory several times.


Steps to Reproduce:

I don't have a good reproducer. The machine is a Lenovo T510 with 4GB of RAM running x86_64 version of RHEL6. Yum is set up to download material from the nightly downloads. The machine is up-to-date as of October 3, 2010.

The machine is a laptop and is put into and taken out of suspend on a regular basis.



  
Actual results:

Nautilus taking almost 2GB of memory. Machine getting very slow and excessive time spent with disk on.


Expected results:

Nautilus taking much less memory, on the orders of 10's of MB not 1.8GB.


Additional info:

Comment 2 William Cohen 2010-10-03 18:54:24 UTC
Created attachment 451300 [details]
Memory map of the problem nautilus

The attached file shows the memory map for the nautilus process leaking memory. There appears to be some very large [anon] regions in the map.

Also tried porting the gdb-heap/gdb from f14 to try to get more details on the memory allocations. See a lot of 9M allocations like the following:

All chunks of memory on heap (both used and free)
-------------------------------------------------
0: 0x00007f37e7cd5000 -> 0x00007f37e859ffff  inuse: 9220096 bytes (<MChunkPtr chunk=0x7f37e7cd5000 mem=0x7f37e7cd5010 prev_size=0 IS_MMAPPED chunksize=9220096 memsize=9220080>)
1: 0x00007f37e85a0000 -> 0x00007f37e8e6afff  inuse: 9220096 bytes (<MChunkPtr chunk=0x7f37e85a0000 mem=0x7f37e85a0010 prev_size=0 IS_MMAPPED chunksize=9220096 memsize=9220080>)
2: 0x00007f37e8e6b000 -> 0x00007f37e9735fff  inuse: 9220096 bytes (<MChunkPtr chunk=0x7f37e8e6b000 mem=0x7f37e8e6b010 prev_size=0 IS_MMAPPED chunksize=9220096 memsize=9220080>)
3: 0x00007f37e9736000 -> 0x00007f37ea000fff  inuse: 9220096 bytes (<MChunkPtr chunk=0x7f37e9736000 mem=0x7f37e9736010 prev_size=0 IS_MMAPPED chunksize=9220096 memsize=9220080>)
4: 0x00007f37ea001000 -> 0x00007f37ea8cbfff  inuse: 9220096 bytes (<MChunkPtr chunk=0x7f37ea001000 mem=0x7f37ea001010 prev_size=0 IS_MMAPPED chunksize=9220096 memsize=9220080>)
5: 0x00007f37ea8cc000 -> 0x00007f37eb196fff  inuse: 9220096 bytes (<MChunkPtr chunk=0x7f37ea8cc000 mem=0x7f37ea8cc010 prev_size=0 IS_MMAPPED chunksize=9220096 memsize=9220080>)
6: 0x00007f37eb197000 -> 0x00007f37eba61fff  inuse: 9220096 bytes (<MChunkPtr chunk=0x7f37eb197000 mem=0x7f37eb197010 prev_size=0 IS_MMAPPED chunksize=9220096 memsize=9220080>)

Comment 3 William Cohen 2010-10-04 00:41:18 UTC
Created attachment 451323 [details]
script to watch for mallocs by nautilus

Wanted to see when and where the mallocs are occurring. The attached is a very simple minded script used with systemtap. Run the script with the pid of nautilus (in this case 5093):

stap   --ldd -v  /tmp/nautstack.stp -x 5093

See lots of places with 0x500000 byte allocations. That is 5MB. Why so many larges allocations. Below is a sample of the output:


nautilus(5093) process("/lib64/libc-2.12.so").function("__libc_malloc@/usr/src/debug/glibc-2.12-2-gc4ccff1/malloc/malloc.c:3614")(bytes=0x500000)
 0x32a3e799d0 : malloc+0x0/0x1f0 [libc-2.12.so]
 0x32ace05994 [libgdk_pixbuf-2.0.so.0.1800.9+0x5994/0x1e000]
nautilus(5093) process("/lib64/libc-2.12.so").function("__libc_malloc@/usr/src/debug/glibc-2.12-2-gc4ccff1/malloc/malloc.c:3614")(bytes=0x8000)
 0x32a3e799d0 : malloc+0x0/0x1f0 [libc-2.12.so]
 0x32a7e1be40 [libpng12.so.0.44.0+0x1be40/0x26000]
nautilus(5093) process("/lib64/libc-2.12.so").function("__libc_malloc@/usr/src/debug/glibc-2.12-2-gc4ccff1/malloc/malloc.c:3614")(bytes=0x500000)
 0x32a3e799d0 : malloc+0x0/0x1f0 [libc-2.12.so]
 0x32ace06435 [libgdk_pixbuf-2.0.so.0.1800.9+0x6435/0x1e000]
nautilus(5093) process("/lib64/libc-2.12.so").function("__libc_malloc@/usr/src/debug/glibc-2.12-2-gc4ccff1/malloc/malloc.c:3614")(bytes=0x500000)
 0x32a3e799d0 : malloc+0x0/0x1f0 [libc-2.12.so]
 0x32ace05994 [libgdk_pixbuf-2.0.so.0.1800.9+0x5994/0x1e000]

Comment 4 William Cohen 2010-10-04 00:55:31 UTC
The machine is being switched back an forth between single head and multi head mode.

Also noticed that gnome-screensaver is taking up a lot of memory on the system:

top - 20:54:38 up 3 days, 10:05,  5 users,  load average: 1.03, 1.14, 0.89
Tasks: 257 total,   2 running, 255 sleeping,   0 stopped,   0 zombie
Cpu(s):  5.7%us,  4.3%sy,  0.0%ni, 72.4%id, 16.7%wa,  0.1%hi,  0.7%si,  0.0%st
Mem:   3716868k total,  3592616k used,   124252k free,    82908k buffers
Swap:  5947384k total,   595084k used,  5352300k free,  1980216k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
 4031 wcohen    20   0 1129m 418m  19m S 10.6 11.5  11:02.18 firefox            
 3345 wcohen    20   0  677m 110m 3524 S  0.0  3.0   0:27.66 gnome-screensav    
 5093 wcohen    20   0  596m  93m  13m S  0.0  2.6   0:05.45 nautilus

Comment 5 Tomáš Bžatek 2010-10-04 10:09:55 UTC
Thanks for debugging this, since Nautilus also manages desktop background, it might be leaking some objects when extending/shrinking the desktop (xrandr events). Or, but unlikely, there's a leak when decoding an image file, either desktop background or some thumbnail elsewhere. 

Try living a moment without desktop background, set it to solid color. This will help us to identify the leak. Still, we might be allocating same sized pixmap with solid color.

Comment 6 William Cohen 2010-10-05 04:12:17 UTC
I will go with the solid background to see if that improves things.

The background was originally the default background that cycles through the various background ?????x????_dawn.png, ????x????_day.png, etc. Not sure what size was being used. The laptop screen doesn't fix the list of resolutions.

The lcd screen of the laptop is 1600x900.  At home I plug it into a viewsonic 1280x1024 monitor into the vga output and and at work I have a princeton monitor that is also 1280x1024. Maybe having the different monitors on the output is triggering the memory leak

If you have some method of running valgrind on nautilus, I am willing to try that out and see where those memory allocations are coming from.

Comment 7 Tomáš Bžatek 2011-01-24 15:13:33 UTC
(In reply to comment #6)
> If you have some method of running valgrind on nautilus, I am willing to try
> that out and see where those memory allocations are coming from.
This is not easy. Try running `nautilus -q` but there's a high risk that session respawns nautilus back automatically. In that case, something like 
> for i in `seq 1 20`; do pkill nautilus; done
might do the trick. If that doesn't help either, try removing filemanager from /desktop/gnome/session/required_components_list gconf key and logout.

Once nautilus is dead, you can try running nautilus under valgrind. Quitting it by `nautilus -q` would show final valgrind report.

Comment 8 Ryan Stanyan 2011-03-17 17:39:22 UTC
I'm having a similar problem with the i386 version of RHEL 6.  I noticed that after changing the background from the default dynamic version of it to a static background the leak has stopped.

Comment 9 Alexander Lindqvist 2011-03-28 17:24:04 UTC
I running the 64bit version and is also affected by this. Atleast when running the dynamic background. Nautilus quickly grows to around 700MB of RAM after a few hours. Any news on this bug ?

Comment 11 Stephane Gauthier 2011-05-11 19:18:42 UTC
Same here. Will verify if user is indeed using any fancy screensaver/wallpaper setup.

Comment 12 Ben Woodard 2011-05-27 18:46:33 UTC
I also have the problem on a X301
I do not have any screensavers at all running. There is the standard
gnome-screensaver lock
I also switch frequently between single head and multihead
I don't have anything fancy for a background just a nasa picture of some
galaxy. However, when the screens resize it does seem to resize or do something
with the background.

It is very hard (as in I haven't been able to do it yet) to attach valgrind to
nautilus because gnome-session. I tried stopping gnome-session and then
starting nautilus but that didn't work.

killing nautilus frees up the memory. gnome-session restarts it quickly.

Comment 13 Kai Meyer 2011-05-31 15:09:36 UTC
I also have this bug on RHEL 6.1 Workstation. It is starting to sound like it's the rotating background image. I used a tool that would generate one for me from some high resolution pictures of my own. It seems to grow about 2GB a day for me.

Killing nautilus also works, and gnome-session also restarts it quickly. So I've been doing that for about a week now.

Comment 14 Kai Meyer 2011-06-01 15:45:53 UTC
With a non-rotating background, my memory usage hasn't changed much at all for Nautilus. It's enough for me to blame the rotating-background feature having a memory leak.

Comment 15 Boris B. Zhmurov 2011-07-05 15:44:03 UTC
I also confirm, that if I change my background to "No Desktop Background", my workstation becomes to usable condition. 

Well, if any of backgrounds, except "no background", are enabled, my desktop is out of memory (4Gb) in a two-three days, even if I don't use it at all!

Comment 16 Michal Šiška 2011-10-11 12:38:44 UTC
I had the same issue on RHEL 6.1 Workstation, MSI G-Series laptop with two external LCDs connected. It seems it has been solved by turning off the default rotating background.

Comment 17 Boris B. Zhmurov 2011-10-11 12:54:58 UTC
It's been more than a year. Still "Status: NEW".
You go, RedHat!

Comment 21 Joshua Roys 2011-11-14 12:00:29 UTC
30197 jroys3    20   0 8554m 5.6g 5496 S  0.0 72.2  10:33.89 nautilus
and
 2874 jroys3    20   0 5760m 4.6g 8232 S  0.0 58.5   6:53.58 nautilus

# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.1 (Santiago)

Comment 22 Tomáš Bžatek 2011-12-02 14:39:06 UTC
Looks like this is fixed upstream: http://git.gnome.org/browse/gnome-desktop/commit/libgnome-desktop/gnome-bg.c?id=af477956ddd06e3821bbcc3e9337a637fe91584a

Tested on local dual-monitor setup with success with the above patch.

Steps to reproduce:
 1. Setup a dualmonitor machine using Gnome desktop
 2. Change the desktop background to rotating one, e.g. 'Cosmos'
 3. To speed up backgrounds changing, edit the '/usr/share/backgrounds/cosmos/background-1.xml' file and change "1795" with a lower value, say "5"
 4. Notice the memory consumption coming up rapidly

Comment 24 Vladimir Benes 2012-01-03 14:19:05 UTC
*** Bug 766889 has been marked as a duplicate of this bug. ***

Comment 26 Joshua Roys 2012-01-17 19:47:43 UTC
After
  884 jroys3    20   0 5416m 4.7g  14m S  0.0 61.6   6:19.76 nautilus
and
  918 jroys3    20   0 2345m 1.6g  20m S  0.0 20.9   2:09.73 nautilus
and
25212 jroys3    20   0 1649m 1.0g  20m S  0.0 12.9   1:18.45 nautilus
and
 7633 jroys3    20   0 5739m 4.4g  17m S  0.0 57.3   6:54.64 nautilus
back-to-back (it would take a under a week usually), I patched gnome-desktop locally and the leak has stopped.

FYI, I don't have rotating backgrounds or anything fancy.  The only thing unusual is two monitors of different screensize/resolutions.

Comment 27 Joshua Roys 2012-01-17 19:57:18 UTC
Actually, I take that back.  They do rotate- I just am never around when they do.  </whine>

Comment 30 Tomáš Bžatek 2012-02-02 11:19:58 UTC
*** Bug 680956 has been marked as a duplicate of this bug. ***

Comment 32 Tomáš Bžatek 2012-02-02 13:14:44 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause: An object not being destroyed

Consequence: Constantly growing resident memory led to memory exhaustion, crashes and system slowdowns.

Fix: A memory leak has been fixed

Result: No more exhaustive memory consumption

Comment 34 Michal Fojtik 2012-02-06 14:35:24 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,7 +1 @@
-Cause: An object not being destroyed
+Previously, due to an object not being destroyed, the Nautilus file manager could consume an excessive amount of memory. Consequently, constantly growing resident memory would slow down the system. The source code has been modified to prevent memory leaks from occurring and Nautilus now consumes a reasonable amount of memory.-
-Consequence: Constantly growing resident memory led to memory exhaustion, crashes and system slowdowns.
-
-Fix: A memory leak has been fixed
-
-Result: No more exhaustive memory consumption

Comment 35 errata-xmlrpc 2012-03-20 13:56:28 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0405.html