Hi Centos Community,
This is my first time here and I apologize in advance if I made a mistake here and hope you will correct me , if i made any.
With that said,
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 http://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 http://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:
1.
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. 2.
Since the glibc 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?
I am posting my environment details in the P.S below.
Regards,
-Anand
P.S:
cat /etc/centos-release
CentOS Linux release 8.4.2105
[root@localhost RSS_measurement]# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
I am running both the centos versions under Virtualbox.