I use Launch4j 3.0.2. I set max heap size 300 MB or 90% of free memory. Created executable fails to run ('Cannot create Java virtual maschine') on Vista 32 bit, 4GB of phisical memory (Vista 'sees' only 3300 in fact).
Previously I used Launch4j 3.0.1 with patch that created grzegok (great thanks to him), see this thread:
This should work, the fix made it to this release. Please run the wrapper with the debug option to see if the heap info will appear.
I've just tested an executable generated by 3.1.0-beta1 (02-12-2012). It fails to start at Windows Vista 32 bit (32 bit JVM), I have 4 GB of physical memory (~3200 MB is visible by 32-bit Windows). I set Max heap size to 500 MB or 90% of free memory.
I used --l4j-debug flag to check the correctness. The output:
Heap limit: Reduced 1602 MB heap size to 32-bit maximum 1500 MB
Heap -Xmx: 500 MB / 90%, Free: 1780 MB, Heap size: 1500 MB
Launcher: C:\Program Files\Java\jre7\bin\javaw.exe
Launcher args: -Xmx1500m -jar "Percent.exe"
Then I tested -Xmx1500m on java - jar (without wrapper), and I checked that it also fails:
java -jar -Xmx1500m Percent.exe
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
I tried to decrease size with step 100 and found experimentally that -Xmx1200m first works. I found some considerations here: http://stackoverflow.com/a/1434882/1705429
"we observed that we could go no further than 1280MB on Windows 32bit. I doubt that running a 32bit JVM under 64bit would make any difference."
So, I thing we should reduce mbLimit32 = 1500 to 1200 in head.c.
On my side, it worked under WinXP up to -Xmx1474m.
It would be nice to find a rule that would work all the time.
I don't know how you got the 1500 number, but Oracle specifies the maximum heap size should be smaller of 1/4th of the physical memory or 1GB. See: http://docs.oracle.com/javase/6/docs/technotes/guides/vm/gc-ergonomics.html
But I wonder whether this document is really accurate, since it's possible to use much more than 1 GB with a 64bit JRE!
It seems to me that the issue is more complicated. Java need contiguous free address space: http://stackoverflow.com/questions/171205/java-maximum-memory-on-windows-xp
For example log file shows Free: 1575 MB, set -Xmx1280m (I set 1280 maximum for 32 bit Java) but JVM shows 'Cannot create Java Virtual machine'.
Therefore the value of MEMORYSTATUSEX.ullAvailPhys may be greater than maximum value with which Java can start. (BTW, MEMORYSTATUS is used in head.c instead MEMORYSTATUSEX which can properly handle >4 GB). And as I understand with 64-bit system the contiguous free address space can be easily obtained.
So I came to a simple algorithm: if we found 32 bit Java, then we set -Xmx500m and it works an most computers; if we found 64-bit Java, we set -Xmx to free memory value.
Thanks for all your comments. The CVS contains a fix for calculating the heap correctly on 64-bit machines (MEMORYSTATUSEX). I reduced the limit for 32-bit to 1024 MB. Let's see how this works. As noted in the forums if you need such a big heap you should use a 64-bit VM. I don't think that free memory guarantees contiguous space. All in all it's also about configuration, requesting 100% of free or available memory is a bit extreme.
As for the 1GB from Oracle, this is not the absolute max, it's a default max heap. Meaning you can set more.
If the problems persist after the release, please reopen this bug.