This is a complicated question and its likely PhDs study this for various reasons.
I use 4096 most of the time. On windows always reserve about 2Gigs for the OS, and I usually try to keep 2 gigs free for other things/chrome/music/etc. I give starmade 4 gigs (4096)