Page 1 of 1

Any ways to further minimize RAM usage?

Posted: Sun Aug 26, 2012 4:19 pm
by nicknml
Are there any other services that I can disable to cut down RAM usage? Right now I don't have anything else running besides the default services that are running and I'm at 54MB of RAM used (before a few updates yesterday, RAM usage was normally around 47M). Will be interesting to see how low I can get.

Re: Any ways to further minimize RAM usage?

Posted: Sun Aug 26, 2012 4:24 pm
by PeterO
How are you calculating the figure of "54M" ? Linux uses memory in several ways.

PeterO

Re: Any ways to further minimize RAM usage?

Posted: Sun Aug 26, 2012 4:25 pm
by nicknml
PeterO wrote:How are you calculating the figure of "54M" ? Linux uses memory in several ways.

PeterO
Using the used figure reported by top.

Re: Any ways to further minimize RAM usage?

Posted: Sun Aug 26, 2012 4:35 pm
by PeterO
Which figure reported by top though ?

Unless you have something in mind which will use all of the ram then you are really wasting you time with this. Let the kernel look after the memory management, it's much better at it than you'll be ! :roll:
PeterO

Re: Any ways to further minimize RAM usage?

Posted: Sun Aug 26, 2012 4:38 pm
by nicknml
The used figure under KiB Mem.

Re: Any ways to further minimize RAM usage?

Posted: Sun Aug 26, 2012 8:45 pm
by nicknml
Didn't realize that the "used" statistic included buffers and cached, so actual memory usage is actually 15M (yea, I don't think I can get much lower than that ;) )

Re: Any ways to further minimize RAM usage?

Posted: Mon Aug 27, 2012 4:31 am
by mpthompson
Yeah, gotta watch out for the memory buffers/cache as the OS discards them if more memory is needed so they really don't count against the memory being used.

A few additional commands you might find useful for tracking memory:

Code: Select all

free -h
and

Code: Select all

cat /proc/meminfo

Re: Any ways to further minimize RAM usage?

Posted: Mon Aug 27, 2012 10:00 pm
by Lartza
nicknml wrote:Didn't realize that the "used" statistic included buffers and cached, so actual memory usage is actually 15M (yea, I don't think I can get much lower than that ;) )
That's not true! :)

Switch openssh to dropbear and /bin/sh to dash from bash.
Disable extra tty's and disable ipv6(might not actually reduce memory usage).
Switch rsyslogd to inetutils-syslogd and disable ntpd (run ntpdate on boot and with cron)
Disable DHCP, set a static IP.

You can probably do still a little more, but not much. I am currently using around 10MB, 1MB more if I log in on a tty and not SSH (for some reason)
(If anyone can think of something else let me know :P)

Re: Any ways to further minimize RAM usage?

Posted: Thu Sep 13, 2012 1:53 am
by headhoncho
some additional stuff i found on reducing RAM use

http://extremeshok.com/blog/debian/rasp ... ory-usage/

Re: Any ways to further minimize RAM usage?

Posted: Thu Sep 13, 2012 4:48 am
by jojopi
Lartza wrote:Switch openssh to dropbear and /bin/sh to dash from bash.
In recent debian, /bin/sh is already dash. But that will not save you much after boot, if your login shell is explicitly bash. Assuming you meant to change login shell to dash, I think you will find that pdksh is considerably smaller still:

Code: Select all

$ for i in bash "busybox sh" dash ksh pdksh zsh; do $i -c '/bin/ps uw $$ && :'; done |sort -unk5
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
pi        4090  0.0  0.0    424   236 pts/0    S+   05:30   0:00 pdksh -c /bin/ps uw $$ && :
pi        4086  0.0  0.2   1744   508 pts/0    S+   05:30   0:00 dash -c /bin/ps uw $$ && :
pi        4084  0.0  0.2   2300   548 pts/0    S+   05:30   0:00 busybox sh -c /bin/ps uw $$ && :
pi        4082  0.0  0.5   4804  1236 pts/0    S+   05:30   0:00 bash -c /bin/ps uw $$ && :
pi        4092  0.0  0.5   5544  1408 pts/0    S+   05:30   0:00 zsh -c /bin/ps uw $$ && :
pi        4088  0.0  0.5   5548  1264 pts/0    S+   05:30   0:00 ksh -c /bin/ps uw $$ && :
Though personally I would not sacrifice interactive usability features like bash's tab completion, just to have 0.5% more memory not being used.