Currently I have an issue with programs not de-allocating their stack upon close. It appears to be a natural behaviour of Linux page caching.
When I open my desktop, it runs at ~300-500MB. After closing a browser to open perhaps another RAM intensive program like Ardour, I notice that the used RAM drops down but the allocated RAM remains largely the same or at best drops to around 2.2GB.
The same issue is discussed on this thread. The solution I found there was to run the following command which clears PageCache only:
sync; echo 1 > /proc/sys/vm/drop_caches
The following clears dentries and inodes:
sync; echo 2 > /proc/sys/vm/drop_caches
The following clears both PageCace AND dentries and inodes:
sync; echo 3 > /proc/sys/vm/drop_caches
However, I don't want to run this every time. I want to have my workspace free to utilize every bit of RAM between programs.
Is there a way to configure PageCache on a system level or do I need to do something janky like running a service with some kind of listener which then triggers the above command on program close?
See the following example, whilst Brave is open:
And another after closing
Here is the RAM on boot:
System info:
kernel: 5.10.56-1-lts
Flava: Arch
Desktop: i3-gaps
Programs tested: Brave, Chromium, Firefox, Ardour, Gimp, Inkscape