4

I don't really know what's going on here at the moment:

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
 1272 root      20   0 3829868 3.312g   1860 D   0.7 93.0 512:39.94 smbd

free -m tells:

             total       used       free     shared    buffers     cached
Mem:          3644       3560         84          7          0         25
-/+ buffers/cache:       3533        110 <--- this is what bugs me
Swap:         4292       2146       2146

Service Definitions:

[global]
        server role = standalone server
        map to guest = Bad User
        obey pam restrictions = Yes
        pam password change = Yes
        passwd program = /usr/bin/passwd %u
        passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
        unix password sync = Yes
        syslog = 0
        log file = /var/log/samba/log.%m
        max log size = 1000
        dns proxy = No
        usershare allow guests = Yes
        panic action = /usr/share/samba/panic-action %d
        idmap config * : backend = tdb


[homes]
        comment = Home Directories
        valid users = %S
        create mask = 0700
        directory mask = 0700
        browseable = No


[printers]
        comment = All Printers
        path = /var/spool/samba
        create mask = 0700
        printable = Yes
        print ok = Yes
        browseable = No


[print$]
        comment = Printer Drivers
        path = /var/lib/samba/printers

#I don't really know what's this, but... it was a working share in its time
[media]
        path = /rem/media/


[rem]
        path = /rem/
        force user = <rem owner username here>
        read only = No
        create mask = 0660
        directory mask = 0770

EDIT: Restarting the smbd service seems to solve the problem, BUT it keeps coming back approx. 2 hours after that.

EDIT2: After shutting down the smbd service, everything seems to be OK:

             total       used       free     shared    buffers     cached
Mem:          3644        123       3521          8          3         36
-/+ buffers/cache:         83       3561
Swap:         4292        230       4062

EDIT3: Here are some more details (asked by Daniel B):

  • The question is: Why is samba eating that much ram?
  • Distro: debian in case you can't read tags :P
  • Version: 4.2.10-Debian
  • Access pattern? No idea what that is :P
  • Large files: Not much, just 2-3 pcs. of 4GB files Small files: A LOT.

EDIT4: It seems like that samba isn't really reading/writing anything while eating RAM:

  TID  PRIO  USER     DISK READ  DISK WRITE  SWAPIN     IO>    COMMAND
 1351 be/4 root        0.00 B/s    3.95 K/s  0.00 %  0.00 % smbd -D

EDIT5: Problem is half-solved using Hastur's advice. Now we're waiting for clients to go ahead and index/scan/do whatever with the samba share what they want.

Current status:

18992 root      20   0  283140   8916   6584 S   1.0  0.2   0:00.32 smbd
18983 root      20   0  284048  14964  11752 S   0.7  0.4   0:00.16 smbd

EDIT6: How interesting:

18983 root      20   0 2964080 2.564g   6044 R  92.1 72.0 853:58.94 smbd

Now it consumes memory AND CPU. Someone, please help! :)

EDIT7: Alright, limited the number of file locks & connections, but STILL NO CHANGE. Eats up my RAM like crazy! Well, at least it suddenly stopped eating CPU.

24606 root      20   0 3768932 3.325g   2332 D  17.3 93.4   1441:50 smbd

Any help is REALLY appreciated. I'm really close to writing a cron job restarting smbd every 24 hours.

  • Your question is missing important details. What distribution? What version of Samba? What type of access pattern is Samba seeing? Many large files? Many small files? And also of course: What’s the question? – Daniel B Apr 29 '16 at 15:27
  • The question is: Why is samba eating that much ram? Distro: debian, in case you can't read tags :P Version: 4.2.10-Debian Access pattern? No idea what that is :P Large files: Not much, just 2-3 pcs. of 4GB files, Small files: A LOT. – ForceMagic Apr 29 '16 at 15:31
  • Did you try to see if all that ram usage decreases with samba active and internet physically disconnected? The implied guess is that some one is indexing from outside your tribes of little files. BTW how many are them? (find . | wc -l). Even more how many in a single directory? If they are too many you can divide in more subpath... – Hastur May 14 '16 at 8:38
  • Files are in separate subdirectories (categorized by date), but actually, I think I'm going to try disconnecting from the internet once the problem appears again. – ForceMagic May 14 '16 at 9:35
  • @Hastur BTW, there you go, output of find . | wc -l: 24128 (Executed from samba share root (/rem/)) – ForceMagic May 16 '16 at 12:23
0

TEMPORARY SOLUTION! This isn't the actual way to solve this problem, but it works out perfectly for me.

  1. (sudo) crontab -e.
  2. Choose nano or vim according to your preference. (If you haven't chose it already)
  3. In the file, add the line 0 [whatever hour (0-23) you want here] * * * service smbd restart

This will restart the smbd (Samba daemon) service on an every day basis.

As I said, this is not the final solution, so if anyone has better solutions, THEN I'll accept an answer.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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