return -1;
}
- public static long memPercentAmount(int percent)
- {
- return memPercentAmount((float)percent);
- }
- public static long memPercentAmount(float percent)
- {
- long memPercentAmount = -1;
-
- long physicalMem = getPhysicalMemory();
- if (physicalMem > MemorySetting.applicationMinMemory)
- {
- // try and set at least applicationMinMemory and thereafter ensure
- // leaveFreeMinMemory is left for the OS
-
- memPercentAmount = (long) ((physicalMem * percent) / 100F);
-
- // check for memory left for OS
- if (physicalMem - memPercentAmount < MemorySetting.leaveFreeMinMemory)
- {
- memPercentAmount = physicalMem - MemorySetting.leaveFreeMinMemory;
- }
-
- // check for minimum application memsize
- if (memPercentAmount < MemorySetting.applicationMinMemory)
- {
- memPercentAmount = MemorySetting.applicationMinMemory;
- }
- } else {
- // not enough memory for application, just try and grab what we can!
- memPercentAmount = physicalMem;
- }
-
- return memPercentAmount;
- }
-
}