Open desktop mechanic

cat /dev/random | grep "For being ignorant to whom it goes I writ at random, very doubtfully"

GNOME memory

Tuesday Feb 22, 2005

A question on the Java Desktop System Developer forum got me to thinking about memory usage of the GNOME desktop and various basic applications. Whenever I give a talk on JDS or GNOME, one of the most common complaints/questions is why does X use so much memory? (Where X is nautilus, metacity, mozilla, clock-applet...)
While answering the forum posting, I learned something. Here is the output of prstat -s size (sorted by resident memory size) on an ordinary Java Desktop System GNOME desktop:

-bash-3.00$ prstat -s size
   PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP
   434 root       58M   23M sleep   59    0   0:00:08 0.1% Xorg/1
   637 root       50M   25M sleep   59    0   0:00:01 0.0% nautilus/4
   658 root       45M   17M sleep   59    0   0:00:07 0.1% gnome-terminal/2
   578 root       41M   16M sleep   59    0   0:00:00 0.0% gnome-session/1
   635 root       39M   14M sleep   59    0   0:00:01 0.0% gnome-panel/1
   593 root       36M 9512K sleep   59    0   0:00:00 0.0% gnome-settings-/1
   650 root       36M   12M sleep   59    0   0:00:00 0.0% wnck-applet/1
   652 root       36M   10M sleep   59    0   0:00:02 0.1% gnome-netstatus/1
   648 root       35M   11M sleep   59    0   0:00:00 0.0% clock-applet/1
   654 root       35M 9784K sleep   59    0   0:00:01 0.0% mixer_applet2/1
   656 root       34M 9120K sleep   59    0   0:00:00 0.0% notification-ar/1
   639 root       34M 8240K sleep   59    0   0:00:00 0.0% gnome-volcheck/1
   640 root       34M 2164K sleep   59    0   0:00:00 0.0% gnome-volcheck/1
   631 root       32M 9892K sleep   59    0   0:00:00 0.0% metacity/1
   583 root       12M   10M sleep   59    0   0:00:01 0.0% gconfd-2/1
     7 root     9944K 7628K sleep   59    0   0:00:02 0.0% svc.startd/12
     9 root     8760K 7780K sleep   59    0   0:00:06 0.0% svc.configd/19
   629 root     7868K 3616K sleep   59    0   0:00:00 0.0% gnome-smproxy/1
   478 root     7692K 2984K sleep   59    0   0:00:00 0.0% dtlogin/1
  1156 root     7468K 3708K sleep   59    0   0:00:00 0.0% sshd/1
  1159 bnitz    7428K 2248K sleep   59    0   0:00:00 0.0% sshd/1
Total: 72 processes, 184 lwps, load averages: 0.01, 0.01, 0.02
35 Meg for a clock applet! Sigh. But wait a minute what is "SIZE" measuring?
man prstat shows:
SIZE
The total virtual memory size of the process, including all mapped files and devices, in kilobytes (K), mega- bytes (M), or gigabytes (G).
Here is an explanation from GNOME's Miguel de Icaza on how to interpret memory statistics In this case size isn't very useful. It just tells us how much address space the process maps, not how much memory the process consumes!

What about resident set size (RSS)? Well it's a somewhat more meaningful statistic, but it also includes memory used by shared libraries. But the whole idea of shared libraries is that they are shared, that is, several processes can use a library without having multiple copies of the library in memory. For a typical GNOME application/applet, everything from libc to libX11, libgtk... is counted multiple times! And as Miguel's article explains, RSS doesn't count memory which is swapped out. So on the one hand we are massively overestimating the memory usage for applications which use many shared libraries (e.g. GNOME applications) and on the other hand we are underestimating the memory usage for applications which may be swapped out.
The manpage for prstat (Solaris) mentions another memory utility called pmap, which can give more detailed memory statistics for a process. For our clock-applet process:
# pmap -x 648
648:    /usr/lib/clock-applet --oaf-activate-iid=OAFIID:GNOME_ClockApplet_Fact
 Address  Kbytes     RSS    Anon  Locked Mode   Mapped File
0803E000      40      40      40       - rwx--    [ stack ]
08048000     132     132       -       - r-x--  clock-applet
08078000      16      16      12       - rwx--  clock-applet
0807C000       4       -       -       - rwx--  clock-applet
0807D000    1260    1248    1248       - rwx--    [ heap ]
D0400000   11476     504       -       - r-x--  libmlib_sse2.so.2
D0F44000     304     128     104       - rwx--  libmlib_sse2.so.2
D0F90000       4       -       -       - rwx--  libmlib_sse2.so.2
D112E000     384     128       -       - rwxs-    [ shmid=null ]
D1190000       4       4       4       - rwx--    [ anon ]
D11A0000       4       4       -       - r-x--  pango-basic-fc.so
D11B0000       8       8       8       - rwx--  pango-basic-fc.so
D11C0000       4       4       -       - r-x--  646%UTF-8.so
D11D0000       8       8       4       - rwx--  646%UTF-8.so
D11E0000       4       4       4       - rwx--    [ anon ]
D11F0000     192     148       -       - r-x--  libpng12.so.0.1.2.5
D122F000       8       8       8       - rwx--  libpng12.so.0.1.2.5
D1240000      12      12       -       - r-x--  libpixbufloader-png.so
D1252000       4       4       4       - rwx--  libpixbufloader-png.so
D1260000      12      12       -       - r-x--  libmp.so.2
D1273000       4       4       4       - rw---  libmp.so.2
D1280000      24      20       -       - r-x--  libuutil.so.1
D1296000       4       4       4       - rw---  libuutil.so.1
D12A0000       4       4       -       - r-x--  libdoor.so.1
D12B1000       4       4       4       - rw---  libdoor.so.1
D12C0000      88      88       -       - r-x--  libscf.so.1
D12E6000       4       4       4       - rw---  libscf.so.1
D12F0000      44      44       -       - r-x--  libblueprint.so
D130A000       4       4       4       - rwx--  libblueprint.so
D1310000       4       4       -       - r-x--  UTF-8%646.so
D1320000       4       4       4       - rwx--  UTF-8%646.so
D132D000      68      60       -       - r----  dev:102,0 ino:5950
D1340000       4       4       -       - r-x--  UTF-8%8859-1.so
D1350000       4       4       4       - rwx--  UTF-8%8859-1.so
D1361000       4       4       -       - rwxs-    [ anon ]
D1370000      12      12      12       - rwx--    [ anon ]
D1380000       4       4       4       - rwx--    [ anon ]
D1390000       4       4       -       - r-x--  libmd5.so.1
D13A1000       4       4       4       - rw---  libmd5.so.1
D13B0000      28      12       -       - r-x--  libaio.so.1
D13C7000       4       4       4       - rw---  libaio.so.1
D13C8000       4       -       -       - rw---  libaio.so.1
D13D0000       4       4       4       - rwx--    [ anon ]
D13E0000     228     156       -       - r-x--  libexpat.so.0.5.0
D1428000       8       8       8       - rwx--  libexpat.so.0.5.0
D1430000       4       4       4       - rwx--    [ anon ]
D1440000       4       4       4       - rwx--    [ anon ]
D1450000      72      52       -       - r-x--  libXext.so.0
D1472000       4       4       4       - rw---  libXext.so.0
D1480000      28      24       -       - r-x--  libXi.so.5
D1497000       4       4       4       - rw---  libXi.so.5
D14A0000      12      12       -       - r-x--  libXrandr.so.2
D14B3000       4       4       4       - rw---  libXrandr.so.2
D14C0000       4       4       4       - rwx--    [ anon ]
D14D0000       4       4       4       - rwx--    [ anon ]
D14E0000      24      20       -       - r-x--  librt.so.1
D14F6000       4       4       4       - rw---  librt.so.1
D1500000      24      20      20       - rwx--    [ anon ]
D1510000     916     428       -       - r-x--  libcrypto.so.0.9.7
D1605000      84      72      72       - rw---  libcrypto.so.0.9.7
D161A000       8       4       4       - rw---  libcrypto.so.0.9.7
D1620000       4       4       4       - rwx--    [ anon ]
D1630000     200      64       -       - r-x--  libssl.so.0.9.7
D1672000      12      12      12       - rw---  libssl.so.0.9.7
D1680000      40      40       -       - r-x--  libORBitCosNaming-2.so.0.0.0
D1699000       8       8       8       - rwx--  libORBitCosNaming-2.so.0.0.0
D16A0000       4       4       4       - rwx--    [ anon ]
D16B0000     108      20       -       - r-x--  libaudiofile.so.0.0.2
D16DA000      12      12      12       - rwx--  libaudiofile.so.0.0.2
D16E0000      28       8       -       - r-x--  libesd.so.0.2.32
D16F6000       8       8       8       - rwx--  libesd.so.0.2.32
D1700000       4       4       4       - rwx--    [ anon ]
D1710000     420     248       -       - r-x--  libfreetype.so.6
D1788000      36      36      36       - rwx--  libfreetype.so.6
D17A0000     200     180       -       - r-x--  libfontconfig.so.1
D17E1000      20      20      20       - rwx--  libfontconfig.so.1
D17E6000       4       4       4       - rwx--  libfontconfig.so.1
D17F0000      24      24       -       - r-x--  libXrender.so.1
D1806000       4       4       4       - rw---  libXrender.so.1
D1810000      60      56       -       - r-x--  libXft.so.2
D182F000       4       4       4       - rw---  libXft.so.2
D1840000       4       4       4       - rwx--    [ anon ]
D1850000     488     392       -       - r-x--  libX11.so.4
D18DA000      16      16      16       - rw---  libX11.so.4
D18E0000       4       4       4       - rwx--    [ anon ]
D18F0000     104      72       -       - r-x--  libjpeg.so.62.0.0
D1919000       4       4       4       - rwx--  libjpeg.so.62.0.0
D1920000      24       8       -       - r-x--  libgailutil.so.17.0.1
D1935000       4       4       4       - rwx--  libgailutil.so.17.0.1
D1940000       4       4       4       - rwx--    [ anon ]
D1950000      28      12       -       - r-x--  libgnome-keyring.so.0.0.0
D1966000       4       4       4       - rwx--  libgnome-keyring.so.0.0.0
D1970000       4       4       4       - rwx--    [ anon ]
D1980000     728     640       -       - r-x--  libc.so.1
D1A46000      24      24      24       - rw---  libc.so.1
D1A4C000       8       8       8       - rw---  libc.so.1
D1A50000      16      16       -       - r-x--  libthread.so.1
D1A60000       4       4       4       - rwx--    [ anon ]
D1A70000     512     400       -       - r-x--  libglib-2.0.so.0.400.1
D1AFF000       4       4       4       - rwx--  libglib-2.0.so.0.400.1
D1B10000       8       8       -       - r-x--  libgmodule-2.0.so.0.400.1
D1B21000       4       4       4       - rwx--  libgmodule-2.0.so.0.400.1
D1B30000     220     220       -       - r-x--  libgobject-2.0.so.0.400.1
D1B76000       4       4       4       - rwx--  libgobject-2.0.so.0.400.1
D1B80000     172     156       -       - r-x--  libpango-1.0.so.0.400.1
D1BBA000      20      20      20       - rwx--  libpango-1.0.so.0.400.1
D1BD0000       4       4       4       - rwx--    [ anon ]
D1BE0000      36      12       -       - r-x--  libpangox-1.0.so.0.400.1
D1BF8000       8       8       8       - rwx--  libpangox-1.0.so.0.400.1
D1C00000    8720     236       -       - r-x--  libmlib.so.2
D2493000      68      32      24       - rwx--  libmlib.so.2
D24B0000      12      12       -       - r-x--  libpangoxft-1.0.so.0.400.1
D24C2000       8       8       8       - rwx--  libpangoxft-1.0.so.0.400.1
D24D0000     268      60       -       - r-x--  libm.so.2
D2522000      16       8       8       - rwx--  libm.so.2
D2530000       4       4       4       - rwx--    [ anon ]
D2540000      80      72       -       - r-x--  libgdk_pixbuf-2.0.so.0.400.9
D2563000       8       8       8       - rwx--  libgdk_pixbuf-2.0.so.0.400.9
D2570000      80      72       -       - r-x--  libatk-1.0.so.0.700.3
D2593000       8       8       8       - rwx--  libatk-1.0.so.0.700.3
D25A0000     372     356       -       - r-x--  libgdk-x11-2.0.so.0.400.9
D260C000      20      20      16       - rwx--  libgdk-x11-2.0.so.0.400.9
D2620000     512     396       -       - r-x--  libnsl.so.1
D26A0000      20      20      20       - rw---  libnsl.so.1
D26A5000      32      24      24       - rw---  libnsl.so.1
D26B0000       4       4       4       - rwx--    [ anon ]
D26C0000      44      36       -       - r-x--  libsocket.so.1
D26DB000       4       4       4       - rw---  libsocket.so.1
D26E0000      40      32       -       - r-x--  libz.so.1
D26F9000       8       8       8       - rwx--  libz.so.1
D2700000      12      12       -       - r-x--  libpthread.so.1
D2710000     864     372       -       - r-x--  libxml2.so.2
D27F7000      40      40      40       - rwx--  libxml2.so.2
D2801000      32       4       4       - rwx--  libxml2.so.2
D2810000       4       4       4       - rwx--    [ anon ]
D2820000    2416    1444       -       - r-x--  libgtk-x11-2.0.so.0.400.9
D2A8B000      40      40      40       - rwx--  libgtk-x11-2.0.so.0.400.9
D2A95000       4       4       4       - rwx--  libgtk-x11-2.0.so.0.400.9
D2AA0000      76      24       -       - r-x--  libglade-2.0.so.0.0.3
D2AC2000       8       8       8       - rwx--  libglade-2.0.so.0.0.3
D2AD0000      12       8       -       - r-x--  libgthread-2.0.so.0.400.1
D2AE2000       4       4       4       - rwx--  libgthread-2.0.so.0.400.1
D2AF0000     216     168       -       - r-x--  libresolv.so.2
D2B36000       8       8       8       - rw---  libresolv.so.2
D2B40000       4       4       4       - rwx--    [ anon ]
D2B50000     252     240       -       - r-x--  libORBit-2.so.0.0.0
D2B9E000      32      32      32       - rwx--  libORBit-2.so.0.0.0
D2BB0000      68      68       -       - r-x--  libbonobo-activation.so.4.0.0
D2BD0000       8       8       8       - rwx--  libbonobo-activation.so.4.0.0
D2BE0000     304     284       -       - r-x--  libgnomevfs-2.so.0.600.0
D2C3B000      20      20      20       - rwx--  libgnomevfs-2.so.0.600.0
D2C40000       4       4       4       - rwx--  libgnomevfs-2.so.0.600.0
D2C50000       4       4       4       - rwx--    [ anon ]
D2C60000     184     184       -       - r-x--  libgconf-2.so.4.1.0
D2C9D000      12      12      12       - rwx--  libgconf-2.so.4.1.0
D2CB0000     292     280       -       - r-x--  libbonobo-2.so.0.0.0
D2D08000      40      40      40       - rwx--  libbonobo-2.so.0.0.0
D2D20000     132      36       -       - r-x--  libpangoft2-1.0.so.0.400.1
D2D50000       4       4       4       - rwx--  libpangoft2-1.0.so.0.400.1
D2D60000      80      12       -       - r-x--  libart_lgpl_2.so.2.3.16
D2D83000       4       4       4       - rwx--  libart_lgpl_2.so.2.3.16
D2D90000       4       4       4       - rwx--    [ anon ]
D2DA0000      24      20       -       - r-x--  libpopt.so.0.0.0
D2DB5000       4       4       4       - rwx--  libpopt.so.0.0.0
D2DC0000      72      72       -       - r-x--  libgnome-2.so.0.600.0
D2DE1000       4       4       4       - rwx--  libgnome-2.so.0.600.0
D2DF0000     156      28       -       - r-x--  libgnomecanvas-2.so.0.600.0
D2E26000       8       8       8       - rwx--  libgnomecanvas-2.so.0.600.0
D2E30000     328     300       -       - r-x--  libbonoboui-2.so.0.0.0
D2E91000      12      12      12       - rwx--  libbonoboui-2.so.0.0.0
D2EA0000       4       4       4       - rwx--    [ anon ]
D2EB0000      64      64       -       - r-x--  libICE.so.6
D2EC0000       4       4       4       - rw---  libICE.so.6
D2EC1000       8       -       -       - rw---  libICE.so.6
D2ED0000      28      28       -       - r-x--  libSM.so.6
D2EE7000       4       4       4       - rw---  libSM.so.6
D2EF0000     524     328       -       - r-x--  libgnomeui-2.so.0.600.1
D2F82000      16      16      16       - rwx--  libgnomeui-2.so.0.600.1
D2F90000       4       4       4       - rwx--    [ anon ]
D2FA0000      56      52       -       - r-x--  libpanel-applet-2.so.0.0.19
D2FBD000       8       8       8       - rwx--  libpanel-applet-2.so.0.0.19
D2FD0000       4       4       -       - r-x--  libdl.so.1
D2FDB000     128     128       -       - r-x--  ld.so.1
D2FFB000       4       4       4       - rwx--  ld.so.1
D2FFC000       8       8       8       - rwx--  ld.so.1
-------- ------- ------- ------- -------
total Kb   36292   12264    2336       -

What does this mean?

Again from the pmap man page. Resident memory is 12264 Kilobytes but much of this physical memory can be shared with other instances of the clock applet. But the anon column, the memory used by each instance of a clock applet, that's kind of high too. Should a clock applet really take over 2 megabytes?
Thanks Yusuf for pointing me to Ben Maurer's blog and a Wiki on GNOME memory usage. I think we're all pulling in the same direction here and as I learn more about which tools can be applied to this problem, I'll try to contribute what I learn.
There is certainly room for improvement on GNOME memory usage, but before we get started we need to make sure we are using meaningful measurements.

[2] Comments
Like this post? del.icio.us | furl | slashdot | technorati | digg

Sailboat beats Dublin Bus

Sunday Feb 06, 2005

Dublin Bay entrance This isn't the best time of year for sailing in Ireland but the weather cooperated on Saturday. We sailed my friend's boat to Dun Laoghaire to have it assessed for a possible trade up. This was the least amount of wind I'd sailed in in Dublin, about 15-20 knots out of the west veering west-southwest. Eyghtheen-24's aren't the fastest sailboat design on the planet, but we averaged a respectable 5.7 Miles/hour. It took us about 2 hours and 13 minutes to travel the 12.7 miles across Dublin bay.

Ideally we would have taken the DART back, but the weirdly planned upgrade project makes it impossible to DART from Dun Laoghaire to anywhere north of Connolly station for 18 months of weekends. So we took Dublin Bus from Dun Loaghaire to near the GPO, walked to the number 42 bus stop and took the 42 bus home. Because of the DART problem, traffic in Dublin was terrible so this journey took more than 2 1/2 hours. This made me wonder why no one has taken advantage of high oil prices and reintroduced sail assisted ferries for locations such as Dublin Bay where the wind is nearly always strong. A modern sailing catemaran could probably cover the distance twice as fast as my friend's sailboat, which would certainly make it competitive with Dublin Bus.

Update: Of course I'm not the first to have thought of this, a hybrid wind and solar powered ferry is already operating in Sydney.

Update: To put things in perspective, (and put me in my place!) Ellen MacArthur sailed 27,000 miles around the world, averaging 14.5 mile/hour 350 miles/day to set a new world record. Way to go Ellen! This is an awesome acheivement which isn't very well understood by today's narrowly focused sports media. The timesonline.co.uk article I linked to seems to have transposed multihulls with monohulls in a few places. Multihulls

    can
capsize and when they do it is nearly impossible to recover. One transoceanic multihull sailer had to cut his way out from the bottom of a multihull a few years back. Another thing you'll notice about multihulls is that the mast must be thicker and stronger to compensate for the fact that the boat can't "heel over" to absorb some of the energy of wind gust. Imagine putting an enormous sail on a telephone pole sized mast and then hearing the mast creak in a rapidly rising wind. Do you take the sail down? If something breaks, there is no one around for a thousand miles...

[0] Comments
Like this post? del.icio.us | furl | slashdot | technorati | digg