Why does Dropbox use so much memory on Linux?
pmap shows that Dropbox uses nearly 200MB of memory (on Linux). When I run Dropbox on Windows, it only uses about 30MB of memory. What is the reason for that?
Also, why are there so many [ anon ]
ranges that occupy so much memory according to pmap output?
[mirror@home Dropbox]$ pgrep dropbox
9544
9544: /home/mirror/.dropbox-dist/dropbox
08048000 3028K r-x-- /home/mirror/.dropbox-dist/dropbox
0833d000 248K rw--- /home/mirror/.dropbox-dist/dropbox
0837b000 52K rw--- [ anon ]
08c20000 15688K rw--- [ anon ]
ad052000 1028K rw--- [ anon ]
ad1d4000 1024K rw--- [ anon ]
ad3d4000 1024K rw--- [ anon ]
ad5d4000 4K ----- [ anon ]
ad5d5000 10240K rw--- [ anon ]
adfd5000 4K ----- [ anon ]
adfd6000 10240K rw--- [ anon ]
ae9d6000 4K ----- [ anon ]
ae9d7000 10240K rw--- [ anon ]
af3d7000 4K ----- [ anon ]
af3d8000 10240K rw--- [ anon ]
afdd8000 4K ----- [ anon ]
afdd9000 10240K rw--- [ anon ]
b07d9000 4K ----- [ anon ]
b07da000 10240K rw--- [ anon ]
b11da000 4K ----- [ anon ]
b11db000 10240K rw--- [ anon ]
b1bdb000 4K ----- [ anon ]
b1bdc000 10240K rw--- [ anon ]
b25dc000 4K ----- [ anon ]
b25dd000 10240K rw--- [ anon ]
b2fdd000 4K ----- [ anon ]
b2fde000 10240K rw--- [ anon ]
........
b7fc6000 4K rw--- /lib/libpthread-2.5.so
b7fc7000 12K rw--- [ anon ]
b7fca000 4K r-x-- /home/mirror/.dropbox-dist/_bisect.so
b7fcb000 4K rw--- /home/mirror/.dropbox-dist/_bisect.so
b7fcc000 20K r-x-- /home/mirror/.dropbox-dist/_struct.so
b7fd1000 4K rw--- /home/mirror/.dropbox-dist/_struct.so
b7fd2000 108K r-x-- /lib/ld-2.5.so
b7fed000 4K r---- /lib/ld-2.5.so
b7fee000 4K rw--- /lib/ld-2.5.so
bfa77000 156K rw--- [ stack ]
total 194620K
pmap
displays the virtual memory of a process – that is, not only locations where the process stores data and stack, but also dynamically loaded libraries, memory-mapped files, shared memory, and so on. Very few of those actually contribute to the resident or shared segments, which would represent actual resource usage.
In other words, you are looking at the wrong numbers. For "memory usage", look at the "RSS" field in ps
, or "RES" in top/htop
.
For example, Dropbox on my system is about 38 MB, even though its virtual memory space is over 1.7 GB.
According to https://www.dropbox.com/en/help/144
Want more details? Dropbox stores metadata on your files in RAM to prevent constant and expensive database lookups while syncing. The metadata includes paths to files in your Dropbox, checksums, modification times, etc.
We are working hard on making this information more compact and are working on several fronts to improve memory usage. Our techniques are not limited to rewriting pieces of our source code and writing custom memory allocators.
Still, on my computer the RES of dropbox is 150MB+ (according to top
). My dropbox contains 4261 files+folders, resulting in 36KB per file... The raw data they mention shouldn't use more than about 200bytes per file. Of course, data structures can have significant overhead.
Just for fun I checked the memory usage of python storing a dictionary of the files in my dropbox folder:
import os
files = { f[0]: (f[0], (1,2,3,4,5), 1, 1) for f in os.walk(".") }
This gives a RSS of 9.6MB
This is very simplified of course, but it seems unlikely that dropbox is doing a very good job keeping a low memory footprint.
PS: This does not seem to be a linux client issue: https://www.dropboxforum.com/hc/en-us/community/posts/204452623-Memory-Usage-Disproportionate-to-Dropbox-Contents
Hi, I'm using Dropbox on Windows7 64bit and am using it to keep just over 500KB over about 200 files synced across my devices.
Anyway, the Dropbox client consistently runs, using 95MB of RAM, which I think is a little unreasonable.
Use pmap -x
to show the extended format, including RSS:
$ pmap -x $(pgrep -x dropbox)
3015: /home/nathaniel/.dropbox-dist/dropbox-lnx.x86_64-26.4.24/dropbox
Address Kbytes RSS Dirty Mode Mapping
0000000000400000 4584 4260 0 r-x-- dropbox
0000000000400000 0 0 0 r-x-- dropbox
0000000000a7a000 120 116 4 r---- dropbox
0000000000a7a000 0 0 0 r---- dropbox
0000000000a98000 360 360 216 rw--- dropbox
0000000000a98000 0 0 0 rw--- dropbox
0000000000af2000 84 80 80 rw--- [ anon ]
. . . . . .
. . . . . .
. . . . . .
00007ffcc8d5b000 8 4 0 r-x-- [ anon ]
00007ffcc8d5b000 0 0 0 r-x-- [ anon ]
ffffffffff600000 4 0 0 r-x-- [ anon ]
ffffffffff600000 0 0 0 r-x-- [ anon ]
---------------- ------- ------- -------
total kB 3031520 214308 169808
This way you can tell the difference between virtual memory and the memory Dropbox is actually using (RSS). Here is a good explanation of process memory:
https://techtalk.intersec.com/2013/07/memory-part-1-memory-types/
If you just want the RSS, you can use ps
like this::
$ ps -o pid,rss,cmd -p $(pgrep -x dropbox)
PID RSS CMD
3015 212768 /home/nathaniel/.dropbox-dist/dropbox-lnx.x86_64-26.4.24/dropbox
I find that Dropbox leaks a lot of memory on Linux,
at least in version 2015.10.28
.
After a week or so the RSS can creep up to more than a GB.
My workaround is to restart it regularly.
Here is a minimal script to restart Dropbox:
# /usr/bin/env sh
dropbox stop
while pgrep -x dropbox > /dev/null
do
dropbox status
sleep 1
done
dropbox start