How to calculate available memory when zram is used?

From: yong w
Date: Sat May 15 2021 - 11:33:57 EST


How to calculate available memory when zram is used?
Available+Swap free memeory is obviously bigger than I actually can
use, because zram can compress memory by compression algorithm and
zram compressed data will occupy memeory too.
Is there any way to calculate available memory accurately?

I think of a way is to count the compression rate of zram in the
kernel. The available memory is calculated as follows:
available + swapfree - swapfree * compress ratio
Is it reasonable?