What Are RSS(RES) and VSZ(VIRT) in Linux Memory Management?
January 8th, 2023
RSS(RES, Resident memory size) and VSZ(VIRT, Virtual memory size) are two frequently seen indicators of how much memory a program is using in the Linux environment, either via ps
or top
. What does each of them stand for?
RSS is the Resident Set Size and is used to show how much memory is allocated to that process and is in RAM. It does not include memory that is swapped out. It does include memory from shared libraries as long as the pages from those libraries are actually in memory. It does include all stack and heap memory.
VSZ is the Virtual Memory Size. It includes all memory that the process can access, including memory that is swapped out, memory that is allocated, but not used, and memory that is from shared libraries.
There is also a new measure PSS(Proportional Set Size) that tracks shared memory as a proportion used by the current process.
RSS | PSS | VSZ | |
---|---|---|---|
Program Binary(500KB) | Only Loaded and Non-swapped(400KB) | Same as RSS(500KB) | Full Size(500KB) |
Shared Libraries(2500KB) | Only Loaded and Non-swapped(1000KB) | RSS evenly partitioned between all processes using(1000KB/2) | Full Size(2500KB) |
Stack/Heap Allocations(200KB) | Actually in Memory(Non-swapped and Non-unused)(100KB) | Same as RSS(100KB) | Full size(200KB) |
Size | 1500KB | 1000KB | 3200KB |
Reference:
- What is RSS and VSZ in Linux memory management
- Man page of
top
On Building OpenSSL and Python Manually
October 8th, 2023
Building OpenSSL manually is sometimes required when building a program such like Python that might depend on high version OpenSSL, especially common on CentOS since CentOS provides only 1.x.x version OpenSSL.
I’m installing OpenSSL as an example here.
export OPSSL_VER=3.0.1
wget https://www.openssl.org/source/openssl-$OPSSL_VER.tar.gz
wget https://www.openssl.org/source/openssl-$OPSSL_VER.tar.gz.sha256
sha256sum openssl-$OPSSL_VER.tar.gz
cat openssl-$OPSSL_VER.tar.gz.sha256
rm openssl-$OPSSL_VER.tar.gz.sha256
tar -xzvf openssl-$OPSSL_VER.tar.gz
cd openssl-$OPSSL_VER/
./config --prefix=/opt/OpenSSL/$OPSSL_VER --openssldir=/opt/OpenSSL/$OPSSL_VER shared zlib
make -j
make test -j
sudo make install
After building OpenSSL, you should check the openssldir
whether being in the correct position. The openssl.cnf
file here is an important configuration file and shall be kept the same as the system one (find it by openssl version -d
).
Then, you should duplicate the system’s cert files to your newly installed OpenSSL, since by default, OpenSSL oes not trust anyone. The certifications shipped with the system will be located at the openssldir
for the system version of OpenSSL, and you should make a soft link of these cert
related files to your openssldir
.
After building OpenSSL, you may manually build Python, ssl
is an dependency of Python, and you should specify the --with-openssl
and detailed openssl directory option to the configure
script.
export OPSSL_VER=3.0.1
export PY_VER=3.8.12
export PY_VER=3.10.10
export LDFLAGS=-L/opt/OpenSSL/$OPSSL_VER/lib64
export LD_LIBRARY_PATH=/opt/OpenSSL/$OPSSL_VER/lib64
# ensure you export these env vars before configure!!!
# Go to python.org download corresponding versino of .xz format
tar -xvf Python-$PY_VER.tar.xz && cd Python-$PY_VER
LDFLAGS="${LDFLAGS} -Wl,-rpath=/opt/OpenSSL/$OPSSL_VER/lib64" ./configure --enable-optimizations --enable-loadable-sqlite-extensions --enable-ipv6 --enable-big-digits --with-lto --with-pymalloc --with-doc-strings --with-openssl=/opt/OpenSSL/$OPSSL_VER --prefix=/opt/Python/$PY_VER
# check if configure log shows that ssl support is correct!
make -j
# make sure no module fails to build!
sudo make install
# Copy or create modulefiles
# sudo cp -r modulefiles/Python /etc/modulefiles
sudo ln -s /opt/Python/$PY_VER/bin/python3 /opt/Python/$PY_VER/bin/python
sudo ln -s /opt/Python/$PY_VER/bin/pip3 /opt/Python/$PY_VER/bin/pip