I often use pgtune to set the memory size, just select the correct information
https://pgtune.leopard.in.ua/