Higher Memory usage(RSS) on centos8 compared to Centos7 for a simple c-function! Help needed !

Issues related to applications and software problems and general support
Post Reply
cs10201
Posts: 1
Joined: 2021/07/06 12:35:53

Higher Memory usage(RSS) on centos8 compared to Centos7 for a simple c-function! Help needed !

Post by cs10201 » 2021/07/06 12:41:44

This is a native example that was written to narrow down the higher RAM usage that we see when we are using Centos8 as opposed to Centos7.

The c-code is very small and looks like this :

#include<stdio.h>

#include<unistd.h>

int main()

{

pause();

return 0;

}

I compile and run the binary on centos7 and memory backed section of pmap output looks like below:

pmap -X $(pidof sleep) | head -n -2 | awk '{ if (NR > 2 && $5 > 0 ) printf "%12s %8s %8s %4s %s\n", $1, $6, $7, $2,$13}'
00400000 4 4 r-xp sleep
00600000 4 4 r--p sleep
00601000 4 4 rw-p sleep
7f54514f9000 1808 204 r-xp libc-2.17.so
7f54516bd000 2044 0 ---p libc-2.17.so
7f54518bc000 16 16 r--p libc-2.17.so
7f54518c0000 8 8 rw-p libc-2.17.so
7f54518c7000 136 108 r-xp ld-2.17.so
7f5451ae8000 4 4 r--p ld-2.17.so
7f5451ae9000 4 4 rw-p ld-2.17.so

and ps says the following:

** ps -o rss= pidof sleep 352**

Running the same binary on centos8 leads to

** ps -o rss= pidof pause 784 **

and the pmap output looks like below:

00400000 4 4 r-xp pause
00600000 4 4 r--p pause
00601000 4 4 rw-p pause
7f24029a8000 1776 788 r-xp libc-2.28.so
7f2402b64000 2044 0 ---p libc-2.28.so
7f2402d63000 16 16 r--p libc-2.28.so
7f2402d67000 8 8 rw-p libc-2.28.so
7f2402d6d000 176 176 r-xp ld-2.28.so
7f2402f99000 4 4 r--p ld-2.28.so
7f2402f9a000 8 8 rw-p ld-2.28.so

For running the same executable, the libc.so takes 788KB(204KB on centos7).

Note:

This is not the only library that is showing this behavior, but we see the same behavior for other shared-library as well as executables that were compiled on centos7. Running the same executables/shared objects take a higher amount of pages on centos8 than on centos7.

Since the libc version on Centos8 was 2.28 , i have compiled 2.17 version and then used patchelf to patch the centos7 built binary to make use of 2.17 glibc on centos8 host like patchelf --set-interpreter

/home/babu/RSS_measurement/2_17_downloaded/glibc_home/lib/ld-linux-x86-64.so.2 --set-rpath /home/babu/RSS_measurement/2_17_downloaded/glibc_home/lib /tmp/pause

and then run it under LD_DEBUG=libs and verified the 2.17 version of libc libraries were used and still the memory usage on centos8 was higher than on centos7 (about the same numbers as above).

What could be the reason for the higher RAM usage on centos8 vs centos7? I can imagine some defaults have changed on centos8 and that has meant this impact and i could change this default and could reproduce the same RSS numbers on centos8 as well?

gregw99
Posts: 2
Joined: 2023/04/17 18:19:38

Re: Higher Memory usage(RSS) on centos8 compared to Centos7 for a simple c-function! Help needed !

Post by gregw99 » 2023/04/17 19:29:07

+1 We are seeing the exact same issue.

Does anybody have insight into why centos8 memory usage is significantly higher than centos7?

Here is some additional info about our issue:
https://serverfault.com/questions/11286 ... ially-ever

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Higher Memory usage(RSS) on centos8 compared to Centos7 for a simple c-function! Help needed !

Post by TrevorH » 2023/04/17 19:44:40

First thing you should do is update your system to something current.

Your quoted kernel version from that link is 4.18.0-348.12.2.el8_5.x86_64 and that is ancient so it's very likely that the rest of your system is too. I'm also not entirely sure what CentOS you are running since CentOS Linux 8 went EOL at the end of 2021 (8.5.2111) but the last kernel I see on vault.centos.org is https://vault.centos.org/8.5.2111/BaseO ... x86_64.rpm and the one mentioned would appear to be newer. Perhaps you converted to Stream 8 but have never run an update since.

If you're still on CentOS Linux 8 then it's been dead for approaching 18 months now and is unsupported. You can migrate from CL8.5 to any of Alma/Rocky/OEL or to CentOS Stream 8 if a permanent beta is your cup of tea. If you've already migrated then run a full `yum update` and get up to date and reboot.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

gregw99
Posts: 2
Joined: 2023/04/17 18:19:38

Re: Higher Memory usage(RSS) on centos8 compared to Centos7 for a simple c-function! Help needed !

Post by gregw99 » 2023/04/17 20:08:23

We are on rocky 8.5 and updated the kernel to 4.18.0-425.19.2.el8_7.x86_64. We also updated the packages, but nothing has changed. We tried Centos 8 (for comparison) and saw the same thing.

Any further insight or suggestions would be greatly appreciated.

chemal
Posts: 776
Joined: 2013/12/08 19:44:49

Re: Higher Memory usage(RSS) on centos8 compared to Centos7 for a simple c-function! Help needed !

Post by chemal » 2023/04/17 20:54:39

You may call this "bloatware" or "evolution" or whatever.

Anyway, RH has increased the minimal memory requirements from 1G (RHEL 7) to 1.5G (RHEL 8), see https://access.redhat.com/articles/rhel-limits.

You can also try RHEL 8 for comparison. My guess is that you will see the same thing again.

BShT
Posts: 583
Joined: 2019/10/09 12:31:40

Re: Higher Memory usage(RSS) on centos8 compared to Centos7 for a simple c-function! Help needed !

Post by BShT » 2023/04/17 21:21:34

try to gcc -S and see
its funny

User avatar
TrevorH
Site Admin
Posts: 33191
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Higher Memory usage(RSS) on centos8 compared to Centos7 for a simple c-function! Help needed !

Post by TrevorH » 2023/04/18 08:14:13

If you're now up to date on everything then the next step is to raise a bugzilla.redhat.com ticket to report the findings and see if you can convince them that this is a problem they need to fix. The RHEL rebuilds will get any fix that RH release once it goes public.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Post Reply