much better memory detection, automatic for sizes 250 on up to 2048

This commit is contained in:
DarthArgus
2016-06-06 00:06:43 -07:00
parent 98b2805867
commit 1be9ef8163

View File

@@ -50,21 +50,30 @@ static bool SetUserSelectedMemoryManagerTarget()
static void SetDefaultMemoryManagerTargetSize()
{
int megabytes = 0;
MEMORYSTATUS memoryStatus;
GlobalMemoryStatus (&memoryStatus);
megabytes = ((memoryStatus.dwTotalPhys / 4) * 3) / (1024 * 1024);
// clamp it between 250 and 2000 MB in production, 750 in dev environments
if (megabytes < 250)
megabytes = 250;
#if PRODUCTION == 0
if (megabytes > 750)
megabytes = 750;
#else
if (megabytes > 2000)
megabytes = 2000;
#endif
MEMORYSTATUSEX memoryStatus;
megabytes = memoryStatus.ullTotalPhys / 1048576;
// clamp it between 250 and 2048MB
if (megabytes >= 2040)
{
megabytes = 2048;
}
else if (megabytes >= 1020)
{
megabytes = 1024;
}
else if (megabytes <= 760)
{
megabytes = 768;
}
else if (megabytes <= 250)
{
megabytes = 256;
}
else
{
megabytes = 768;
}
MemoryManager::setLimit(megabytes, false, false);
}