6

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

4 Answers 4

8

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.

4
  • what is virtual memory? physical memory + swap space?
    – hugemeow
    Sep 6, 2012 at 18:41
  • 3
    @hugemeow: No – it's the memory address space of a process. (Processes cannot access RAM or swap directly – they can only access "virtual" addresses, which the kernel translates to RAM/swap belonging to that process, RAM/swap belonging to shared libraries, data in a mmap()ed file, or something else. Every process has a separate virtual address space of its own.)
    – user1686
    Sep 6, 2012 at 18:55
  • so is there a lot of parts that constitue process's memory, for example stack, heap, shared space(which can be used by many process, right?)
    – hugemeow
    Sep 6, 2012 at 19:03
  • @hugemeow: Right. (Other parts are the "code" (the program itself), various kinds of "memory-mapped files", and probably some other parts that I forget.) Only some parts actually "use" your RAM/swap.
    – user1686
    Sep 6, 2012 at 19:12
3

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.

1

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
-1

I also noticed that Dropbox was using almost all available memory on Linux Mint 17.1 and later on 18.0.

I saw this when I opened System Monitor, clicked the "Processes" tab, and clicked the top of the "Memory" column to sort by largest memory usage.

A reboot did not fix the problem. After a reboot Dropbox restarted the process of using more and more memory.

This worked for me, but read the warning below first:

Change permissions of files in your dropbox folder.

sudo chmod 755 -R ~/Dropbox

Reboot the machine, or kill all dropbox processes and restart dropbox. Note: "dropbox stop" may not be enough.

Run this and you should see "Up to date"

dropbox status

Warning: If you saved config files to Dropbox that have permissions other than 755, restoring those files with altered permissions may break things. You can find ways to save and restore file permissions if that is a concern. At least copy the original file to a different file name before restoring the Dropbox version. Then you will know what the original permissions were if something breaks. Or edit the original file that has correct permissions - copy and paste the part of the dropbox file you want, replacing or adding to the original file.

4
  • 3
    Note that this opens up any files in that directory to reading and writing by ANYONE on your system. That's fine if this is a single-user system, but catastrophically awful if your system allows other users. Feb 20, 2016 at 15:40
  • How do you know that running chmod fixed the memory usage problem if you rebooted the machine afterward? I find that simply restarting Dropbox will also reduce its memory use, though only temporarily. May 26, 2017 at 18:04
  • @bariumbitmap Yes, after rebooting Dropbox gradually uses more and more memory as it tries to sync files that it does not have permission to access. I edited my original post. May 27, 2017 at 20:08
  • @ChrisInEdmonton Perhaps chmod 655 would have fixed the problem, but since mine is a single user system I just went with chmod 777. To work around config files that must have certain owners / permissions, I open the original config file and paste the info from my altered permissions backup file. May 27, 2017 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.