macOS has been doing this a while and this is the root of why users report 8GB macs easily handle more applications than 8GB Windows boxen. Since quite a long time ago, apple silicon even has hardware for this. Literally cpu instructions that do ram compression:
https://asahilinux.org/docs/hw/cpu/apple-instructions/