+ long physicalMem = MemoryPercent.getPhysicalMemory();
+ if (physicalMem > applicationMinMemory)
+ {
+ // try and set at least applicationMinMemory and thereafter ensure
+ // leaveFreeMinMemory is left for the OS
+
+ pcmem = (long) ((physicalMem * percent) / 100F);
+
+ // check for memory left for OS
+ if (physicalMem - pcmem < leaveFreeMinMemory)
+ {
+ pcmem = physicalMem - leaveFreeMinMemory;
+ System.out.println("MemorySetting Property '"
+ + maxHeapSizePerCentProperty + "' (" + jvmmempcorig
+ + ") too large. Leaving free space for OS, using ("
+ + pcmem + ").");
+ }
+
+ // check for minimum application memsize
+ if (pcmem < applicationMinMemory)
+ {
+ pcmem = applicationMinMemory;
+ System.out.println("MemorySetting Property '"
+ + maxHeapSizePerCentProperty + "' (" + jvmmempcorig
+ + ") too small, using minimum (" + applicationMinMemory
+ + ").");
+ }
+ }
+ else
+ {
+ // not enough memory for application, just try and grab what we can!
+ pcmem = physicalMem;
+ System.out.println("MemorySetting Property '"
+ + maxHeapSizePerCentProperty + "' (" + jvmmempcorig
+ + "): Not enough memory, using max available (" + pcmem
+ + ").");
+ }
+