Swoncen
Posts: 19
Joined: Fri Jan 02, 2015 11:03 am

Raspbian samba memory leak

Sun Sep 27, 2015 9:13 pm

Hello,

Recently I've installed a samba service on my Raspberry PI 2, which is running Raspbian. Everything is working, but the access to the files is very slow, especially in folders with a lot of files in it (e.g.: pictures). I've just logged in on my RPI via ssh and watched the processes with "top" on the pi and I realized, that during a file copy (on Linux Mint Cinnamon 32 bit 17.2) via Nemo the memory usage increases a lot. For example: the total memory usage is at 300 MB. I copy 100 pictures from one folder to another and after that, the memory usage goes up to 700 MB and stays there until I do the next copy. Even browsing increases the memory usage, until the memory is full and then it is painfully slow. I'm using Linux since a few months, so I'm not sure which information I should give. I'll start with my RPI setup:

RPI 2 with a USB hub and 2 external WD drives on the hub
raspbian wheezy on a Samsung 16 GByte SD card
running services: kodi, trac, samba, git

My guess is, that some services are conflicting each other, but to be honest I'm not sure and I need your help. I think in kodi, there is an option for samba, maybe this is a problem, I will check that now.

top output looks like this:

Code: Select all

^[[7m  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+  COMMAND                                             $
^[(B^[[m^[[1m 3589 pi        20   0  5228 2620 2240 R  16,5  0,3   0:00.07 top                                         $
^[(B^[[m 3031 pi        15  -5  281m  49m  31m S   5,5  6,0   1:36.30 kodi.bin                                         $
^[(B^[[m    1 root      20   0  2252 1336 1236 S   0,0  0,2   0:02.05 init                                             $
^[(B^[[m    2 root      20   0     0    0    0 S   0,0  0,0   0:00.00 kthreadd                                         $
^[(B^[[m    3 root      20   0     0    0    0 S   0,0  0,0   0:00.19 ksoftirqd/0                                      $
^[(B^[[m    5 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 kworker/0:0H                                     $
^[(B^[[m    6 root      20   0     0    0    0 S   0,0  0,0   0:00.19 kworker/u8:0                                     $
^[(B^[[m    7 root      20   0     0    0    0 S   0,0  0,0   0:00.66 rcu_preempt                                      $
^[(B^[[m    8 root      20   0     0    0    0 S   0,0  0,0   0:00.00 rcu_sched                                        $
^[(B^[[m    9 root      20   0     0    0    0 S   0,0  0,0   0:00.00 rcu_bh                                           $
^[(B^[[m   10 root      rt   0     0    0    0 S   0,0  0,0   0:00.02 migration/0                                      $
^[(B^[[m   11 root      rt   0     0    0    0 S   0,0  0,0   0:00.03 migration/1                                      $
^[(B^[[m   12 root      20   0     0    0    0 S   0,0  0,0   0:00.02 ksoftirqd/1                                      $
^[(B^[[m   14 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 kworker/1:0H                                     $
^[(B^[[m   15 root      rt   0     0    0    0 S   0,0  0,0   0:00.02 migration/2                                      $
^[(B^[[m   16 root      20   0     0    0    0 S   0,0  0,0   0:00.02 ksoftirqd/2                                      $
^[(B^[[m   17 root      20   0     0    0    0 S   0,0  0,0   0:00.00 kworker/2:0                                      $
^[(B^[[m   18 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 kworker/2:0H                                     $
^[(B^[[m   19 root      rt   0     0    0    0 S   0,0  0,0   0:00.03 migration/3                                      $
^[(B^[[m   20 root      20   0     0    0    0 S   0,0  0,0   0:00.02 ksoftirqd/3                                      $
^[(B^[[m   22 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 kworker/3:0H                                     $
^[(B^[[m   23 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 khelper                                          $
^[(B^[[m   24 root      20   0     0    0    0 S   0,0  0,0   0:00.00 kdevtmpfs                                        $
^[(B^[[m   25 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 netns                                            $
^[(B^[[m   26 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 perf                                             $
^[(B^[[m   27 root      20   0     0    0    0 S   0,0  0,0   0:00.00 khungtaskd                                       $
^[(B^[[m   28 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 writeback                                        $
^[(B^[[m   29 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 crypto                                           $
^[(B^[[m   30 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 bioset                                           $
^[(B^[[m   31 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 kblockd                                          $
^[(B^[[m   33 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 rpciod                                           $
^[(B^[[m   34 root      20   0     0    0    0 S   0,0  0,0   0:00.00 kswapd0                                          $
^[(B^[[m   35 root      20   0     0    0    0 S   0,0  0,0   0:00.00 fsnotify_mark
^[(B^[[m   36 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 nfsiod                                           $
^[(B^[[m   42 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 kthrotld                                         $
^[(B^[[m   44 root       1 -19     0    0    0 S   0,0  0,0   0:00.37 VCHIQ-0                                          $
^[(B^[[m   45 root       1 -19     0    0    0 S   0,0  0,0   0:00.06 VCHIQr-0                                         $
^[(B^[[m   46 root       0 -20     0    0    0 S   0,0  0,0   0:00.00 VCHIQs-0                                         $
thanks in advance

RobHenry
Posts: 452
Joined: Fri Sep 21, 2012 9:04 pm
Location: UK

Re: Raspbian samba memory leak

Sun Sep 27, 2015 10:37 pm

This is unlikely to be a memory leak, which is a build up of orphaned memory not freed when it is no longer needed by the application that allocated it.

Are you familiar with memory usage on Linux? Have a look at this page: http://www.linuxatemyram.com

It may be normal for large chunks of memory to be used by a samba server when copying image files, particularly if the client machine is trying to create thumbnails, but it shouldn't impact performance, unless there is insufficient memory to complete a task in which case the pi will grind to a halt since disk i/o is so slow when using swap.

If you are sharing between linux machines only then try using nfs - it is considered more efficient than samba.

Swoncen
Posts: 19
Joined: Fri Jan 02, 2015 11:03 am

Re: Raspbian samba memory leak

Mon Sep 28, 2015 12:11 am

Hello RobHenry,

thank you very much for your help. I didn't know about the way linux uses memory. Everyday I learn a little bit Linux by using it and I love it more each day. However, Nemo is still very slow and I think it may be the thumbnail preview. I havent figured out how to turn it off in Nemo, but for now, I installed the XFE file browser and it is very fast as I would expect it to be =)

I don't like the user interface of XFE so much, but using it for my network shares only is a good trade-off for now.

EDIT: Unfortunately I have some Windows machines which also need access to the network shares, so I would stick with samba instead of nfs.
EDIT 2: I turned thumbnails off in Nemo and it's fast now. =)

Return to “Troubleshooting”