Skip to content
devlinman edited this page Jan 25, 2026 · 4 revisions

Why SOO Much Memory?

  • WhatsApp stores all the encryption keys, messages, and encryption algorithms in webpage memory. This is more or less needed for the end-to-end encryption security guarantees.
  • Is it a design flaw? YES. Can we do something about it? NO.
  • I tried to decode the cached messages on disk, tried to separate the graphics renderer (view) from the message notifier, etc.
  • None of these approaches worked for me. Eventually I just accepted defeat.

THE CULPRIT

  • The core app spawns a few QtWebEngineProcess --type=renderer processes. They consume memory when web.whatsapp.com is rendered.

The Final Solution

  • Enabling Use Less Memory toggle will unload the webpage web.whatsapp.com and keep a _blank page in QWebEngineView when the app is hidden.
  • When the app is raised or shown, the view is forced to load web.whatsapp.com again.

Warning

If you enable Use Less Memory, the webpage is temporarily closed. but the app remains in tray. CPU consumption will increase each time the app is opened and the webpage is loaded.

The Kill Switch

  • Enabling the Kill switch will start a timer process (starts at app launch) which checks for the app's RSS (Resident Set Size = memory pages currently in RAM.) and exits the app if it is greater than the threshold given by the user.
  • Note that RSS is only an approximation/guesstimation of the app's actual memory footprint.
  • It may be better to use PSS (Proportional Set Size) but for now, we are using RSS.
  • Drawbacks of using RSS: double-counts shared library pages in memory. So in effect, the kill switch may be activated prematurely, even when the actual memory consumption is lower than the threshold.
  • Note that neither RSS nor PSS will give the memory readout that you may see from a System Monitor App (like the one in KDE).

The most accurate/acceptable approximation

  • Accurate total memory footprint for our app is given by summing its own PSS, and PSS of all its QtWebEngine subprocesses recursively over the child process tree.
  • You can try writing a shell script that can take the pid of the app and calculate this mess.
  • Implementing such a convoluted and complicated approximation will make the app more complicated than it needs to be. It is a C++ app after all...

Where does it leave us in the end?

  • Like all things in life, it is about balance.
  • if you are frequently using the app, then keep the app in memory. Disable Use Less Memory.
  • Alternatively, remove old/unused chats. Each chat has its own encryption keys, etc. so decreasing the number of chats will reduce memory usage.
  • If you need the app to autostart, but you don't use the app often, use the toggle. Rest assured that the app will load WhatsApp Web when you need to send a message/check messages.

Clone this wiki locally