# Gentoo consumes much more memory than Ubuntu

## chugunium

Dear all,

I have an old PC with 2Gb RAM and I want to use it as a xfce-desktop. I had upgraded Gentoo to actual, had installed xfce and had configured it. I have expected that RAM consumption would be about 300-350 mb after login but it was 500+ mb (free) / 1.1+ gb (ps_mem). 

After that I had installed xubuntu 20.04 alongside Gentoo and had configured xfce same way (plugins, panel, autostart, etc). Memory consumption was ~350mb (free) / ~450 (ps_mem).

I think that incorrect kernel config may cause such consumption but I'm not sure. And I don't know what to do to find out what is the cause. Maybe somebody can help me here.

Some data.

emerge --info: https://bpa.st/FDWA

lshw: https://bpa.st/GUBA

lspci -v: https://bpa.st/G4MA

.config: https://pastebin.com/VBsDGjPH

Some memory consumption info.

Gentoo after loading lxdm screen

```

# free

              total        used        free      shared  buff/cache   available

Mem:        2044372      118816     1714488        2848      211068     1892768

Swap:       7999484           0     7999484

# free -h

              total        used        free      shared  buff/cache   available

Mem:          1,9Gi       115Mi       1,6Gi       2,0Mi       206Mi       1,8Gi

Swap:         7,6Gi          0B       7,6Gi

# ps_mem 

 Private  +   Shared  =  RAM used   Program

148.0 KiB + 248.0 KiB = 396.0 KiB   init

176.0 KiB + 284.0 KiB = 460.0 KiB   bootlogd

184.0 KiB + 308.0 KiB = 492.0 KiB   acpid

280.0 KiB + 450.0 KiB = 730.0 KiB   fcron

584.0 KiB + 716.0 KiB =   1.3 MiB   dhcpcd

364.0 KiB +   1.1 MiB =   1.5 MiB   lxdm-binary

640.0 KiB +   1.0 MiB =   1.6 MiB   dbus-daemon

912.0 KiB +   2.6 MiB =   3.5 MiB   agetty (6)

  1.2 MiB +   2.8 MiB =   3.9 MiB   console-kit-daemon

  2.0 MiB +   2.3 MiB =   4.3 MiB   bash

  2.1 MiB +   3.1 MiB =   5.2 MiB   nmbd

  1.9 MiB +   4.5 MiB =   6.4 MiB   syslog-ng (2)

  3.1 MiB +   3.4 MiB =   6.4 MiB   systemd-udevd

  2.1 MiB +   4.9 MiB =   7.1 MiB   sshd (2)

  5.0 MiB +   8.0 MiB =  13.0 MiB   NetworkManager

  5.7 MiB +  18.2 MiB =  23.9 MiB   smbd (4)

 12.8 MiB +  14.9 MiB =  27.7 MiB   polkitd

 28.6 MiB +  44.7 MiB =  73.2 MiB   lxdm-greeter-gtk

 49.5 MiB +  64.6 MiB = 114.2 MiB   Xorg

---------------------------------

                        295.2 MiB

=================================

```

xubuntu after loading lxdm screen:

```

# free

              total        used        free      shared  buff/cache   available

Mem:        2033772      176496     1443388        1900      413888     1705476

Swap:       7999484           0     7999484

# free -h

              total        used        free      shared  buff/cache   available

Mem:          1,9Gi       172Mi       1,4Gi       1,0Mi       404Mi       1,6Gi

Swap:         7,6Gi          0B       7,6Gi

# python3 Downloads/ps_mem.py 

 Private  +   Shared  =  RAM used   Program

228.0 KiB +  50.5 KiB = 278.5 KiB   acpid

204.0 KiB + 101.5 KiB = 305.5 KiB   anacron

308.0 KiB +  56.5 KiB = 364.5 KiB   agetty

324.0 KiB + 133.5 KiB = 457.5 KiB   cron

344.0 KiB + 135.5 KiB = 479.5 KiB   rtkit-daemon

348.0 KiB + 272.5 KiB = 620.5 KiB   lxdm-binary

464.0 KiB + 158.5 KiB = 622.5 KiB   irqbalance

560.0 KiB + 402.5 KiB = 962.5 KiB   su

476.0 KiB + 620.0 KiB =   1.1 MiB   avahi-daemon (2)

952.0 KiB + 313.0 KiB =   1.2 MiB   kerneloops (2)

  1.0 MiB + 611.5 KiB =   1.6 MiB   systemd-timesyncd

  1.4 MiB + 269.5 KiB =   1.6 MiB   sudo

  1.2 MiB + 662.5 KiB =   1.8 MiB   systemd-logind

  1.3 MiB + 629.5 KiB =   1.9 MiB   accounts-daemon

  1.4 MiB + 710.0 KiB =   2.1 MiB   dbus-daemon (2)

  2.2 MiB + 136.5 KiB =   2.4 MiB   rsyslogd

  2.2 MiB + 974.5 KiB =   3.1 MiB   cupsd

  2.8 MiB + 663.5 KiB =   3.5 MiB   polkitd

  2.4 MiB +   1.4 MiB =   3.8 MiB   bash (2)

  2.5 MiB +   1.9 MiB =   4.3 MiB   cups-browsed

  4.4 MiB + 162.5 KiB =   4.6 MiB   systemd-udevd

  4.7 MiB +   1.1 MiB =   5.8 MiB   systemd-resolved

  5.1 MiB + 864.5 KiB =   5.9 MiB   udisksd

  2.5 MiB +   3.8 MiB =   6.3 MiB   sshd (3)

  4.3 MiB +   4.8 MiB =   9.0 MiB   systemd (3)

  7.4 MiB +   1.9 MiB =   9.3 MiB   NetworkManager

  9.0 MiB +   1.6 MiB =  10.6 MiB   pulseaudio

  9.3 MiB +   2.6 MiB =  11.9 MiB   networkd-dispat

 16.8 MiB +   2.5 MiB =  19.3 MiB   lxdm-greeter-gtk

 58.7 MiB + 940.5 KiB =  59.6 MiB   Xorg

 72.0 MiB +   4.8 MiB =  76.8 MiB   systemd-journald

---------------------------------

                        251.6 MiB

=================================

```

Gentoo after login to xfce session:

```

# free

              total        used        free      shared  buff/cache   available

Mem:        2044372      516556     1237628        3220      290188     1492860

Swap:       7999484           0     7999484

# free -h

              total        used        free      shared  buff/cache   available

Mem:          1,9Gi       503Mi       1,2Gi       3,0Mi       283Mi       1,4Gi

Swap:         7,6Gi          0B       7,6Gi

# ps_mem 

 Private  +   Shared  =  RAM used   Program

148.0 KiB + 194.0 KiB = 342.0 KiB   init

176.0 KiB + 228.0 KiB = 404.0 KiB   bootlogd

184.0 KiB + 244.0 KiB = 428.0 KiB   acpid

280.0 KiB + 358.0 KiB = 638.0 KiB   fcron

352.0 KiB + 480.0 KiB = 832.0 KiB   dbus-launch

388.0 KiB + 614.0 KiB =   1.0 MiB   lxdm-binary

392.0 KiB + 658.0 KiB =   1.0 MiB   lxdm-session

584.0 KiB + 648.0 KiB =   1.2 MiB   dhcpcd

652.0 KiB + 672.0 KiB =   1.3 MiB   ssh-agent

752.0 KiB + 912.0 KiB =   1.6 MiB   gpg-agent

676.0 KiB +   1.0 MiB =   1.7 MiB   gvfsd-metadata

792.0 KiB +   1.1 MiB =   1.9 MiB   gvfs-mtp-volume-monitor

924.0 KiB +   1.2 MiB =   2.1 MiB   xfconfd

  1.1 MiB +   1.4 MiB =   2.6 MiB   gnome-keyring-daemon

  1.2 MiB +   1.5 MiB =   2.7 MiB   console-kit-daemon

  1.1 MiB +   1.6 MiB =   2.7 MiB   gvfs-gphoto2-volume-monitor

  1.0 MiB +   1.7 MiB =   2.7 MiB   gsettings-helper

900.0 KiB +   1.8 MiB =   2.7 MiB   agetty (6)

  1.0 MiB +   1.8 MiB =   2.8 MiB   gvfs-afc-volume-monitor

960.0 KiB +   1.9 MiB =   2.8 MiB   gvfsd

  1.2 MiB +   2.3 MiB =   3.5 MiB   gvfsd-trash

  1.4 MiB +   2.0 MiB =   3.5 MiB   dbus-daemon (2)

  1.5 MiB +   2.3 MiB =   3.8 MiB   upowerd

  2.0 MiB +   2.1 MiB =   4.1 MiB   bash

  1.9 MiB +   2.9 MiB =   4.8 MiB   gvfs-udisks2-volume-monitor

  2.1 MiB +   2.9 MiB =   5.1 MiB   nmbd

  1.9 MiB +   4.0 MiB =   5.9 MiB   syslog-ng (2)

  3.0 MiB +   3.2 MiB =   6.1 MiB   systemd-udevd

  1.9 MiB +   4.4 MiB =   6.3 MiB   sshd (2)

  4.6 MiB +   5.7 MiB =  10.3 MiB   udisksd

  4.7 MiB +   6.1 MiB =  10.8 MiB   NetworkManager

  5.2 MiB +   6.5 MiB =  11.6 MiB   pulseaudio

  5.7 MiB +  17.6 MiB =  23.3 MiB   smbd (4)

 13.2 MiB +  14.0 MiB =  27.2 MiB   polkitd

 18.7 MiB +  20.8 MiB =  39.6 MiB   xfce4-volumed-pulse

 18.5 MiB +  22.2 MiB =  40.7 MiB   xfce4-notifyd

 18.7 MiB +  22.4 MiB =  41.0 MiB   panel-15-systra

 19.5 MiB +  22.1 MiB =  41.6 MiB   xfsettingsd

 19.1 MiB +  22.6 MiB =  41.7 MiB   xfce4-power-manager

 18.9 MiB +  22.8 MiB =  41.7 MiB   xfce4-screensaver

 18.7 MiB +  23.8 MiB =  42.5 MiB   xfce4-clipman

 19.4 MiB +  23.3 MiB =  42.6 MiB   Thunar

 19.6 MiB +  23.4 MiB =  43.1 MiB   xfce4-session

 20.1 MiB +  23.8 MiB =  43.9 MiB   tumblerd

 19.0 MiB +  25.3 MiB =  44.3 MiB   panel-20-alsa

 20.0 MiB +  25.8 MiB =  45.8 MiB   xfce4-panel

 20.4 MiB +  26.4 MiB =  46.9 MiB   panel-2-whisker

 20.9 MiB +  27.0 MiB =  47.9 MiB   xfwm4

 21.5 MiB +  28.6 MiB =  50.0 MiB   nm-applet

 22.3 MiB +  28.0 MiB =  50.4 MiB   panel-19-xkb

 26.9 MiB +  34.1 MiB =  61.1 MiB   panel-16-weathe

 33.6 MiB +  40.6 MiB =  74.2 MiB   xfdesktop

 58.7 MiB +  61.2 MiB = 120.0 MiB   Xorg

---------------------------------

                          1.1 GiB

=================================

```

xubuntu after login to xfce session:

```

# free

              total        used        free      shared  buff/cache   available

Mem:        2033772      363072     1176976        2212      493724     1516712

Swap:       7999484           0     7999484

# free -h

              total        used        free      shared  buff/cache   available

Mem:          1,9Gi       354Mi       1,1Gi       2,0Mi       482Mi       1,4Gi

Swap:         7,6Gi          0B       7,6Gi

# python3 Downloads/ps_mem.py 

 Private  +   Shared  =  RAM used   Program

204.0 KiB +  48.5 KiB = 252.5 KiB   anacron

228.0 KiB +  30.5 KiB = 258.5 KiB   acpid

308.0 KiB +  32.5 KiB = 340.5 KiB   agetty

324.0 KiB +  70.5 KiB = 394.5 KiB   cron

344.0 KiB +  83.5 KiB = 427.5 KiB   rtkit-daemon

348.0 KiB + 107.5 KiB = 455.5 KiB   lxdm-binary

464.0 KiB +  77.5 KiB = 541.5 KiB   irqbalance

692.0 KiB +  17.5 KiB = 709.5 KiB   ssh-agent

560.0 KiB + 275.5 KiB = 835.5 KiB   su

824.0 KiB + 179.5 KiB =   1.0 MiB   gvfs-mtp-volume-monitor

476.0 KiB + 550.0 KiB =   1.0 MiB   avahi-daemon (2)

828.0 KiB + 217.5 KiB =   1.0 MiB   gpg-agent

952.0 KiB + 167.0 KiB =   1.1 MiB   kerneloops (2)

796.0 KiB + 339.5 KiB =   1.1 MiB   lxdm-session

996.0 KiB + 141.5 KiB =   1.1 MiB   xfconfd

996.0 KiB + 148.5 KiB =   1.1 MiB   gvfs-goa-volume-monitor

  1.1 MiB + 154.5 KiB =   1.3 MiB   gnome-keyring-daemon

  1.2 MiB + 161.5 KiB =   1.3 MiB   gvfsd-fuse

980.0 KiB + 406.5 KiB =   1.4 MiB   gvfsd

  1.1 MiB + 272.5 KiB =   1.4 MiB   gvfs-gphoto2-volume-monitor

  1.3 MiB + 207.5 KiB =   1.5 MiB   accounts-daemon

  1.0 MiB + 539.5 KiB =   1.5 MiB   systemd-timesyncd

  1.4 MiB + 182.5 KiB =   1.6 MiB   sudo

  1.2 MiB + 443.5 KiB =   1.6 MiB   gvfsd-trash

  1.4 MiB + 423.5 KiB =   1.8 MiB   gvfs-afc-volume-monitor

  1.2 MiB + 596.5 KiB =   1.8 MiB   systemd-logind

  2.2 MiB +  91.5 KiB =   2.3 MiB   rsyslogd

  1.9 MiB + 732.5 KiB =   2.6 MiB   polkit-gnome-authentication-agent-1

  2.1 MiB + 544.5 KiB =   2.7 MiB   gvfs-udisks2-volume-monitor

  2.2 MiB + 532.0 KiB =   2.7 MiB   dbus-daemon (2)

  2.2 MiB + 670.5 KiB =   2.8 MiB   cupsd

  2.2 MiB + 814.5 KiB =   3.0 MiB   xfce4-notifyd

  2.9 MiB + 233.5 KiB =   3.1 MiB   polkitd

  2.1 MiB +   1.4 MiB =   3.5 MiB   cups-browsed

  2.4 MiB +   1.3 MiB =   3.7 MiB   bash (2)

  4.4 MiB + 129.5 KiB =   4.5 MiB   systemd-udevd

  4.5 MiB + 849.5 KiB =   5.4 MiB   udisksd

  4.4 MiB + 986.5 KiB =   5.4 MiB   systemd-resolved

  2.4 MiB +   3.7 MiB =   6.0 MiB   sshd (3)

  6.9 MiB +   1.4 MiB =   8.4 MiB   NetworkManager

  7.7 MiB +   1.0 MiB =   8.7 MiB   panel-5-systray

  4.5 MiB +   4.5 MiB =   9.0 MiB   systemd (3)

  7.8 MiB +   1.2 MiB =   9.0 MiB   pulseaudio

  8.3 MiB + 967.5 KiB =   9.2 MiB   Thunar

  8.2 MiB +   1.3 MiB =   9.5 MiB   xfce4-screensaver

  8.7 MiB +   1.1 MiB =   9.8 MiB   xfsettingsd

  9.2 MiB +   1.9 MiB =  11.2 MiB   networkd-dispat

  9.2 MiB +   2.3 MiB =  11.5 MiB   panel-6-whisker

 11.1 MiB + 797.5 KiB =  11.8 MiB   tumblerd

  9.5 MiB +   2.7 MiB =  12.2 MiB   xfwm4

  8.9 MiB +   3.4 MiB =  12.3 MiB   panel-10-pulsea

  9.4 MiB +   3.1 MiB =  12.6 MiB   xfce4-panel

 11.1 MiB +   3.7 MiB =  14.8 MiB   nm-applet

 12.6 MiB +   2.6 MiB =  15.2 MiB   panel-15-xkb

 13.3 MiB +   2.7 MiB =  16.1 MiB   panel-19-weathe

 23.0 MiB +   3.5 MiB =  26.4 MiB   xfdesktop

 20.2 MiB +   7.2 MiB =  27.4 MiB   xfce4-session

 55.7 MiB +   6.6 MiB =  62.3 MiB   Xorg

 78.1 MiB +   5.2 MiB =  83.3 MiB   systemd-journald

---------------------------------

                        455.2 MiB

=================================

```

Thanks,

Yuri

----------

## alamahant

If you add the used memory and the buffer/cached memory in both cases xubuntu seems to comsume more.

```

503Mi  +    283Mi  Gentoo=786M

354Mi  +    482Mi   Xubuntu=836M

```

Maybe some "sysctl" tweak or maybe a better kernel .config or a grub parameter for Xubuntu makes for better mem management.

Yet again you cant compare pears and oranges.Xubuntu is systemd and Gentoo is Openrc no?

Xubuntu's tweaking is being performed by a many many people working on it,whereas Gentoo you just configured your self no????

They are bound to have better results even when working on something as controversial as (X)ubuntu...

 :Smile: 

Please do this:

In Gentoo run:

```

echo 1 > /proc/sys/vm/drop_caches

echo 2 > /proc/sys/vm/drop_caches

echo 3 > /proc/sys/vm/drop_caches

```

And check again memory usage...

However having said all that a minimal level of systemd(systemctl preset-all) can also have surpising low mem consumption I recently discovered..

My stats after having just booted in into my new systemd-xfce Gentoo system:

```

Tasks: 232 total,   1 running, 231 sleeping,   0 stopped,   0 zombie

%Cpu(s):  0.4 us,  0.8 sy,  0.0 ni, 96.7 id,  2.1 wa,  0.0 hi,  0.0 si,  0.0 st

MiB Mem :  15897.9 total,  15326.8 free,    321.8 used,    249.3 buff/cache

MiB Swap:      0.0 total,      0.0 free,      0.0 used.  15239.4 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                      

   1755 root      20   0    6104   3360   2672 R   3.8   0.0   0:00.03 top                                          

      1 root      20   0   12724   8728   5952 S   0.0   0.1   0:01.28 systemd                                      

      2 root      20   0       0      0      0 S   0.0   0.0   0:00.00 kthreadd                                     

      3 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_gp                                       

      4 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 rcu_par_gp                                   

      5 root      20   0       0      0      0 I   0.0   0.0   0:00.00 kworker/0:0-events                           

      6 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 kworker/0:0H-events_highpri                  

      7 root      20   0       0      0      0 I   0.0   0.0   0:00.02 kworker/u16:0-events_unbound                 

      8 root       0 -20       0      0      0 I   0.0   0.0   0:00.00 mm_percpu_wq                                 

      9 root      20   0       0      0      0 S   0.0   0.0   0:00.01 ksoftirqd/0                                  

     10 root      -2   0       0      0      0 S   0.0   0.0   0:00.00 rcuc/0                                       

     11 root      -2   0       0      0      0 I   0.0   0.0   0:00.03 rcu_preempt                                  

     12 root      -2   0       0      0      0 S   0.0   0.0   0:00.00 rcub/0                                       

     13 root      rt   0       0      0      0 S   0.0   0.0   0:00.00 migration/0                                  

     14 root     -51   0       0      0      0 S   0.0   0.0   0:00.00 idle_inject/0                                

     15 root      20   0       0      0      0 I   0.0   0.0   0:00.01 kworker/0:1-events                           

     16 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/0                                      

     17 root      20   0       0      0      0 S   0.0   0.0   0:00.00 cpuhp/1                                      

```

And the "ps_mem" thingie.

```

ps_mem

 Private  +   Shared  =  RAM used   Program

232.0 KiB + 394.0 KiB = 626.0 KiB   agetty

324.0 KiB + 508.0 KiB = 832.0 KiB   syndaemon

660.0 KiB + 690.0 KiB =   1.3 MiB   ssh-agent

760.0 KiB + 836.0 KiB =   1.6 MiB   gpg-agent

484.0 KiB +   1.1 MiB =   1.6 MiB   su

816.0 KiB +   1.1 MiB =   1.9 MiB   dbus-launch (2)

644.0 KiB +   1.3 MiB =   1.9 MiB   systemd-timesyncd

912.0 KiB +   1.2 MiB =   2.1 MiB   xfconfd

956.0 KiB +   1.6 MiB =   2.6 MiB   systemd-resolved

  1.2 MiB +   1.9 MiB =   3.1 MiB   systemd-logind

  1.1 MiB +   2.1 MiB =   3.2 MiB   gsettings-helper

  1.4 MiB +   1.9 MiB =   3.3 MiB   upowerd

  1.3 MiB +   2.0 MiB =   3.3 MiB   systemd-networkd

  1.6 MiB +   2.0 MiB =   3.7 MiB   gvfsd

  2.1 MiB +   2.3 MiB =   4.4 MiB   lvmetad

  1.9 MiB +   3.0 MiB =   5.0 MiB   dbus-daemon (3)

  1.3 MiB +   4.1 MiB =   5.4 MiB   bash (2)

  2.0 MiB +   3.8 MiB =   5.8 MiB   lightdm (2)

  3.0 MiB +   3.6 MiB =   6.6 MiB   systemd-udevd

  3.4 MiB +   4.6 MiB =   8.0 MiB   gvfs-udisks2-volume-monitor

  4.8 MiB +   6.9 MiB =  11.7 MiB   polkit-gnome-authentication-agent-1

  4.9 MiB +   6.8 MiB =  11.7 MiB   xfce4-notifyd

  5.1 MiB +   6.8 MiB =  11.9 MiB   xfce4-power-manager

  5.0 MiB +   7.2 MiB =  12.2 MiB   panel-6-systray

  5.4 MiB +   7.8 MiB =  13.2 MiB   xfce4-session

  5.1 MiB +   8.1 MiB =  13.2 MiB   panel-14-action

  5.6 MiB +   7.9 MiB =  13.5 MiB   Thunar

  6.1 MiB +   7.4 MiB =  13.5 MiB   pulseaudio

  5.3 MiB +   8.3 MiB =  13.6 MiB   xfce4-screensaver

  5.9 MiB +   8.2 MiB =  14.0 MiB   xfsettingsd

  6.2 MiB +   7.9 MiB =  14.1 MiB   udisksd

  5.5 MiB +   9.0 MiB =  14.5 MiB   panel-9-power-m

  5.9 MiB +  10.6 MiB =  16.5 MiB   panel-10-notifi

  4.8 MiB +  12.0 MiB =  16.8 MiB   systemd.bak (3)

  7.5 MiB +  11.6 MiB =  19.1 MiB   xfce4-panel

 14.6 MiB +  15.7 MiB =  30.3 MiB   polkitd

 13.1 MiB +  20.2 MiB =  33.3 MiB   xfce4-terminal

 15.9 MiB +  19.0 MiB =  34.9 MiB   xfdesktop

 15.5 MiB +  28.8 MiB =  44.3 MiB   xfwm4

 30.4 MiB +  32.1 MiB =  62.5 MiB   named

 26.9 MiB +  39.4 MiB =  66.3 MiB   systemd-journald

 34.2 MiB +  45.2 MiB =  79.4 MiB   Xorg

---------------------------------

                        626.5 MiB

=================================

```

...And I have bind running also.

No sysctl tweaks.

Just kernel 5.6.10 from kernel.org compiled with an arch .config file.

 :Smile: 

----------

## dmpogo

As you may notice, the difference comes mainly from 'shared' part of the memory, which is almost non-existent in Ubuntu relative to Gentoo.  I would actually wonder how shared memory is even counted into the total, since by it is meaning, this is one that the process shared with other.   Perhaps somebody could explain what is happening with shared memory here.

----------

## Ant P.

I'm more used to seeing such wildly inaccurate comparisons being made to windows. Any tool that accounts shared memory separately per process then adds it up arithmetically is incompetently built.

The dangers of trusting random code off of Microsoft hosting services, I guess…

----------

## chugunium

alamahant,

 *alamahant wrote:*   

> 
> 
> If you add the used memory and the buffer/cached memory in both cases xubuntu seems to comsume more.
> 
> 

 

I know, but I don't understand why "Used" by Gentoo larger than Ubuntu.

 *alamahant wrote:*   

> 
> 
> Xubuntu's tweaking is being performed by a many many people working on it,whereas Gentoo you just configured your self no????
> 
> They are bound to have better results even when working on something as controversial as (X)ubuntu...
> ...

 

Yes, I am the only member of my team  :Smile: 

But I'm trying to reach better results than I already did  :Smile: 

 *alamahant wrote:*   

> 
> 
> Please do this:
> 
> In Gentoo run:
> ...

 

Before

```

              total        used        free      shared  buff/cache   available

Mem:        2044376      475548     1288500        3216      280328     1534404

Swap:       7999484           0     7999484

```

After

```

              total        used        free      shared  buff/cache   available

Mem:        2044376      476216     1442960        3216      125200     1535644

Swap:       7999484           0     7999484

```

Cache was partially dropped, it is expected behavior, "used" remains the same.

dmpogo, yes, you are right, "private" memory parts are comparable, but shared parts are much different and it is very strange for me to see it.

Ant P. Sorry for it, I was wrong to use summary from ps_mem in my first post. But "private" and "shared" shows interesting and inexplicable (for me) difference.

----------

## chugunium

I had tried gentoo-kernel-bin - nothing ever changed, 500+mb after login.

After that I have tried to boot Gentoo using Ubuntu kernel. I successfully booted and logged in, but memory consumption remains the same.

After that I take 'sysctl -a' from Ubuntu and Gentoo and wrote the script to find difference.

```

Difference (Ubuntu # Gentoo): 

fs.dentry-state=20310   4310   45   0   434   0 # 26106   9548   45   0   2374   0

fs.file-max=9223372036854775807 # 197766

fs.file-nr=6848   0   9223372036854775807 # 3520   0   197766

fs.inode-nr=20972   1417 # 23794   520

fs.inode-state=20972   1417   0   0   0   0   0 # 23794   520   0   0   0   0   0

fs.protected_fifos=1 # 0

fs.protected_regular=2 # 0

fs.quota.syncs=0 # 4

kernel.kptr_restrict=1 # 0

kernel.ns_last_pid=4486 # 3093

kernel.perf_event_max_sample_rate=9000 # 100000

kernel.pid_max=4194304 # 32768

kernel.printk=4   4   1   7 # 1   4   1   7

kernel.printk_devkmsg=on # ratelimit

kernel.pty.nr=1 # 3

kernel.random.boot_id=7fe361fc-c780-4079-81fc-0a7286127eca # 625fe4d8-188d-4fb6-bc6a-4cd71bf17d06

kernel.random.entropy_avail=3364 # 1413

kernel.random.uuid=270b4e7a-84b7-427d-8cd0-421ea5dcab39 # 2a6ecec6-b3fa-4b0e-b4cb-39d50c7d0b2d

kernel.sched_domain.cpu0.domain0.max_newidle_lb_cost=1092651 # 2348

kernel.sched_domain.cpu0.domain1.max_newidle_lb_cost=478376 # 4067

kernel.sched_domain.cpu1.domain0.max_newidle_lb_cost=943327 # 1938

kernel.sched_domain.cpu1.domain1.max_newidle_lb_cost=786815 # 4434

kernel.sched_domain.cpu2.domain0.max_newidle_lb_cost=947187 # 2813

kernel.sched_domain.cpu2.domain1.max_newidle_lb_cost=1163001 # 2548

kernel.sched_domain.cpu3.domain0.max_newidle_lb_cost=1236443 # 3064

kernel.sched_domain.cpu3.domain1.max_newidle_lb_cost=1260546 # 4935

kernel.sysrq=176 # 438

net.core.default_qdisc=fq_codel # pfifo_fast

net.ipv4.conf.all.rp_filter=2 # 0

net.ipv4.conf.default.promote_secondaries=1 # 0

net.ipv4.conf.default.rp_filter=2 # 0

net.ipv4.conf.enp4s0.rp_filter=2 # 0

net.ipv4.conf.lo.promote_secondaries=1 # 0

net.ipv4.ping_group_range=0   2147483647 # 1   0

net.ipv6.conf.all.use_tempaddr=2 # 0

net.ipv6.conf.default.use_tempaddr=2 # 0

net.ipv6.conf.enp4s0.accept_ra=0 # 1

net.ipv6.conf.enp4s0.accept_ra_defrtr=1 # 0

net.ipv6.conf.enp4s0.accept_ra_pinfo=1 # 0

net.ipv6.conf.enp4s0.accept_ra_rtr_pref=1 # 0

net.ipv6.conf.enp4s0.use_tempaddr=2 # 0

net.unix.max_dgram_qlen=512 # 10

vm.user_reserve_kbytes=61705 # 61721

Process finished with exit code 0

```

It seems that there is no parameters here that can help me.

----------

## Banana

you can't really compare since the configurations are not the same.

As alamahant already said xubuntu is a ready build. Gentoo you need to do it by yourself. The basic installtion guidlines provide a working gentoo installtion. To create a system which uses less memory you need to tweek on the right places.

----------

## bambus89

Something is going wrong in your system. I have installed gentoo with Kernel 5.6.15, full disk encryption and a full blown Plasma desktop and after boot my system needs 550-700 mb fo ram...  :Very Happy: 

The kernel i use is gentoo-kernel and for initramfs it uses dracut and the .config is the default config enabled all options comes with the kernel... so also full blown...

edit:

free -h:

```

             gesamt       benutzt     frei      gemns.  Puffer/Cache verfügbar

Speicher:        15Gi       438Mi        14Gi       164Mi       717Mi        14Gi

Swap:            0B          0B          0B

```

ps_mem

```

Private  +   Shared  =  RAM used       Program

 96.0 KiB + 124.0 KiB = 220.0 KiB       start_kdeinit

344.0 KiB + 552.0 KiB = 896.0 KiB       lvmetad

460.0 KiB + 978.0 KiB =   1.4 MiB       su

656.0 KiB +   1.1 MiB =   1.8 MiB       dconf-service

928.0 KiB +   1.8 MiB =   2.7 MiB       systemd-timesyncd

  1.1 MiB +   1.9 MiB =   3.0 MiB       gsettings-helper

  1.0 MiB +   2.0 MiB =   3.0 MiB       startplasma-x11

  1.4 MiB +   1.8 MiB =   3.1 MiB       obexd

  1.2 MiB +   2.2 MiB =   3.3 MiB       systemd-logind

  1.4 MiB +   2.1 MiB =   3.5 MiB       sudo

  1.7 MiB +   2.0 MiB =   3.8 MiB       bash

  1.6 MiB +   2.3 MiB =   4.0 MiB       upowerd

  1.9 MiB +   2.1 MiB =   4.0 MiB       bluetoothd

  2.0 MiB +   2.9 MiB =   4.9 MiB       thermald

  2.2 MiB +   3.0 MiB =   5.2 MiB       dbus-daemon (2)

  2.6 MiB +   2.6 MiB =   5.2 MiB       dhclient

  2.0 MiB +   3.3 MiB =   5.3 MiB       sddm

  2.1 MiB +   3.5 MiB =   5.7 MiB       sddm-helper

  2.2 MiB +   4.1 MiB =   6.3 MiB       xembedsniproxy

  3.2 MiB +   3.2 MiB =   6.4 MiB       haveged

  2.3 MiB +   4.2 MiB =   6.5 MiB       kscreen_backend_launcher

  2.4 MiB +   4.4 MiB =   6.8 MiB       gmenudbusmenuproxy

  3.1 MiB +   4.1 MiB =   7.1 MiB       wpa_supplicant

  3.4 MiB +   4.3 MiB =   7.7 MiB       systemd-udevd

  3.7 MiB +   4.2 MiB =   7.8 MiB       fish

  2.8 MiB +   5.2 MiB =   7.9 MiB       plasma_session

  4.5 MiB +   6.0 MiB =  10.5 MiB       udisksd

  4.8 MiB +   7.1 MiB =  11.9 MiB       baloo_file

  4.1 MiB +   8.0 MiB =  12.1 MiB       kactivitymanagerd

  4.5 MiB +   9.2 MiB =  13.7 MiB       klauncher

  6.1 MiB +   8.2 MiB =  14.3 MiB       NetworkManager

  3.4 MiB +  10.9 MiB =  14.3 MiB       systemd (3)

  5.9 MiB +  10.1 MiB =  16.0 MiB       kglobalaccel5

  5.9 MiB +  12.1 MiB =  18.0 MiB       org_kde_powerdevil

  7.0 MiB +  11.9 MiB =  18.9 MiB       kaccess

  7.3 MiB +  12.2 MiB =  19.4 MiB       kwalletd5

  7.5 MiB +  12.7 MiB =  20.2 MiB       DiscoverNotifier

  7.4 MiB +  12.8 MiB =  20.2 MiB       polkit-kde-authentication-agent-1

  7.5 MiB +  13.4 MiB =  20.9 MiB       ksmserver

 10.6 MiB +  12.7 MiB =  23.3 MiB       pulseaudio

 13.9 MiB +  15.0 MiB =  28.9 MiB       polkitd

 16.2 MiB +  31.7 MiB =  47.9 MiB       kded5

 22.7 MiB +  31.5 MiB =  54.2 MiB       Xorg

 21.5 MiB +  54.0 MiB =  75.5 MiB       kdeinit5 (7)

 60.8 MiB +  84.4 MiB = 145.2 MiB       kwin_x11

 75.8 MiB +  93.8 MiB = 169.6 MiB       systemd-journald

116.9 MiB + 150.9 MiB = 267.8 MiB       plasmashell

---------------------------------

                          1.1 GiB

=================================

```

Neofetch

```

Memory: 630MiB / 15897MiB 

```

----------

## Banana

 *Quote:*   

> .config is the default config enabled all options comes with the kernel... so also full blown...

 

The default activated ones or really every single option available?

----------

## bambus89

i think there are all options enabled because all my hardware even peripherals works all ootb

----------

## dmpogo

 *bambus89 wrote:*   

> i think there are all options enabled because all my hardware even peripherals works all ootb

 

If you mean, install gentoo-kernel,   do make menconfig,  save and exit immediately (which generates .config without you having changed anything)  as default, then no, not alll options will be  enabled. Many defaults are set to 'No'

----------

## bambus89

But i have an i2c touchpad from elan which i can say for some times with the genkernel-kernel install from handbook never worked... and with this kernel i do nothing and just all works out of the box...

edit:

If you mean that i invoke menuconfig then no... i do nothing and this process is fully automated. so maybe the install script does or a default gentoo .config will be loaded... i don't know. And even it is not "Full blown" most of the modules are in. I don't think that is does that much to ram usage...

----------

## chugunium

Finally, I have found the reason!

I have an old videocard, NVIDIA GTX-280 and I use nvidia driver for it (not nouveau).

All the tests that I had posted here before I have done with

```

# eselect opengl list

Available OpenGL implementations:

  [1]   nvidia *

  [2]   xorg-x11

```

But after

```

# eselect opengl set 2

Switching to xorg-x11 OpenGL interface... done

# eselect opengl list

Available OpenGL implementations:

  [1]   nvidia

  [2]   xorg-x11 *

# reboot

```

I have got

```

# free

              total        used        free      shared  buff/cache   available

Mem:        2044376      292856     1475296        3244      276224     1717088

Swap:       7999484           0     7999484

```

I have repeated it 6 times (3 reboot with nvidia opengl and 3 with xorg-x11 opengl) and result was the same: ~300mb with xorg-x11 and 500+mb with nvidia.

It is looks very, very strange for me. And I totally don't understand what I can do with it.

And in Ubuntu the same nvidia-drivers are used, hm.

----------

## dmpogo

So to summarize,   using nvidia-drivers on Gentoo leads to extra 200 Mb as compared to Ubiuntu ?   xorg-X11 opengl on both Gentoo and Ubuntu behaves the same ?

I'll try to compare it on my machine with old nvidia card.  What drivers are you using nvidia-drivers-340 ?

Since you are using nvidia-drivers, in your Gentoo kernel configuration did you clear out  Direct Rendering Manager option in "Graphics Support" ?

----------

## chugunium

 *dmpogo wrote:*   

> 
> 
> So to summarize,   using nvidia-drivers on Gentoo leads to extra 200 Mb as compared to Ubiuntu ?
> 
> 

 

yes

 *dmpogo wrote:*   

> 
> 
> xorg-X11 opengl on both Gentoo and Ubuntu behaves the same ?
> 
> 

 

Yes, Xubuntu consumes ~350 mb after login regardless the drivers, Gentoo consumes 500+ using nvidia and ~300 using xorg-x11

 *dmpogo wrote:*   

> 
> 
> I'll try to compare it on my machine with old nvidia card.  What drivers are you using nvidia-drivers-340 ?
> 
> 

 

Thank you!

Yes, I use

```

[ebuild   R    ] x11-drivers/nvidia-drivers-340.108:0/340::gentoo  USE="X acpi multilib static-libs tools" ABI_X86="(64) -32 (-x32)" 0 KiB

```

Unfortunally, it is the last supported version for my old card.

 *dmpogo wrote:*   

> 
> 
> Since you are using nvidia-drivers, in your Gentoo kernel configuration did you clear out  Direct Rendering Manager option in "Graphics Support" ?
> 
> 

 

Device Drivers / Graphic support

```

  │ │                                 < > /dev/agpgart (AGP Support)  ----                                                                   │ │  

  │ │                                 [*] VGA Arbitration                                                                                    │ │  

  │ │                                 (16)  Maximum number of GPUs                                                                           │ │  

  │ │                                 [ ] Laptop Hybrid Graphics - GPU switching support                                                     │ │  

  │ │                                 < > Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)  ----                              │ │  

  │ │                                 [ ] Enable DisplayPort CEC-Tunneling-over-AUX HDMI support                                             │ │  

  │ │                                     ARM devices  ----                                                                                  │ │  

  │ │                                     ACP (Audio CoProcessor) Configuration  ----                                                        │ │  

  │ │                                     Frame buffer Devices  --->                                                                         │ │  

  │ │                                     Backlight & LCD device support  --->                                                               │ │  

  │ │                                     Console display driver support  --->                                                               │ │  

  │ │                                 [ ] Bootup logo  ----    

```

Device Drivers / Graphic support / Device Drivers / Graphic support

```

  │ │                                 [*] VGA text console                                                                                   │ │  

  │ │                                 [*]   Enable Scrollback Buffer in System RAM                                                           │ │  

  │ │                                 (128)   Scrollback Buffer Size (in KB)                                                                 │ │  

  │ │                                 [ ]     Persistent Scrollback History for each console by default                                      │ │  

  │ │                                 (80) Initial number of console screen columns                                                          │ │  

  │ │                                 (25) Initial number of console screen rows                                                             │ │  

  │ │                                 [*] Framebuffer Console support                                                                        │ │  

  │ │                                 [*]   Map the console to the primary display device                                                    │ │  

  │ │                                 [ ]   Framebuffer Console Rotation                                                                     │ │  

  │ │                                 [ ]   Framebuffer Console Deferred Takeover  

```

----------

## dmpogo

Well  one my card is of yours generation, and one is even older - both on 340 drivers  :Smile: 

What I am think is that under Gentoo nvidia kernel modules are compiled on a spot during installation,  while how they are compiled for Ubuntu, who knows,  may be even by Nvidia themselves.

So perhaps Gentoo version is 'more generic'  and has some more generous build options,   reserving extra space or whatever,   maybe part of GPU memory is premapped to RAM  (and it is shared, i,e can be used by other processes if needed).   While in Ubuntu it is done on as-needed basis.  I am just speculating

----------

## chugunium

Cool!

It will be very interesting to see memory consumption in your case:)

About nvidia and ubuntu ... may be ... anyway there is any reason for it   :Smile: 

----------

## chugunium

 *dmpogo wrote:*   

> 
> 
> What I am think is that under Gentoo nvidia kernel modules are compiled on a spot during installation,  while how they are compiled for Ubuntu, who knows,  may be even by Nvidia themselves.
> 
> 

 

I thought about it yesterday, and I have remembered one fact.

When I tested different cases trying to determine the reason of difference in memory consumption, there was the following case: I had copied Xubuntu kernel with modules (nvidia drivers was successfully installed in Xubuntu) to Gentoo and I had booted Gentoo with it. Memory consumption with Xubuntu kernel was the same as with Gentoo kernel - 500+mb (inside Gentoo environment). But inside Xubuntu environment memory consumption was 350-360mb. Interesting fact. So I think that there is a chance that there is some misconfiguration in preferences of my Gentoo system and it is a reason of high memory consumption.

I mean that there is a chance for me to find and fix it. Because if it is a special build for ubuntu, there is no hope  :Smile: 

----------

