More generic computation of memory settings