Check this answer regarding configuring ZRAM which should allow the build to succeed: Is it possible to build AOSP on 32GB RAM?
Also consider using a docker build environment that is already known to successfully build AOSP, see: Unable to compile AOSP source code on Ubuntu 24.04 system