The problem you're having may have more to do with the background process limit introduced in android 12 than with ram management. If you're on android 12 I think I remember there being an adb command that can change the limit from 32 to something else, though I may be mistaken. I think on newer versions of android you might be able to change it in developer settings. Though it's worth checking the Dev settings even if your ROM is based on android 12, since its possible the ROM changed or added options regarding the limit.
If that is in fact the problem you're having, and you find a good solution for android 12, let me know, I really need to see about fixing things on my pixel 3 so stuff like tasker and kwgt, and autonotification, don't constantly stop working ๐