barrydyson
Posts: 1
Joined: Fri Oct 23, 2009 8:15 am

JNI Exception: Failed to create the Java VM

Fri Oct 23, 2009 8:33 am

I know this issue has been raised once or twice before on this forum but, to my knowledge, the issue has never been resolved.

Advanced Installer creates the executable that launches my application. A number of customers have been unable to run the application with this launcher because they are presented with an error dialog saying, "JNI exception: failed to create the Java VM. Reason: not enough memory."

In each case there is sufficient memory available to run the application. The maximum heap size is set to 1024 Mb and the PCs have between 2 and 4 Gb of RAM installed. Furthermore, writing my own launcher with the same parameters as the AI launcher works, as does a bat file.

My question is, why does the AI launcher fail when others do not? What is the AI launcher doing that is different?

Below are the contents of the launcher's ini file.

[Display]
Preffer Native Splash Screen=Yes
Splash Screen=C:\LPB\bin\splashscreen.gif
[Java Runtime Environment]
Maximum Version=any
JRE Path=C:\LPB\jre\
JVM Source=favor_JRE
JVM Type=favor_client
Virtual Machine Parameters=-Xmx1024M -Duser.dir="C:\LPB\bin\"
Minimum Version=1.6
Main Class=com.lbp.ui.browser.application.Browser
[Product Information]
Product Code={16156D04-FBBC-437C-9216-4AB40FEAE5A5}
Product Name=LPB 1.2
Upgrade Code={C461D1BC-900B-42AE-9462-24F8F7CB18CE}
[Application]
Application Type=gui
Failure Check=yes
Single Instance=yes
[Class Path]
Class Path=C:\LPB\lib\lpb.jar;

Thank you for your time.

Barry

ps. "Preffer Native Splash Screen" should be "Prefer Native Splash Screen"

GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact:  Website

Re: JNI Exception: Failed to create the Java VM

Fri Oct 23, 2009 2:26 pm

Hello,

Thank you for bringing this to our attention.

This seems to occur because of added functionality (like Trial, Splash Screen) which impact the launcher even if they are not enabled. We are working on solving this issue and an improvement will be available with a future version of Advanced Installer.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/

p35t173nc3
Posts: 33
Joined: Wed Apr 02, 2008 1:20 pm

Re: JNI Exception: Failed to create the Java VM

Thu Jan 14, 2010 10:36 am

Any idea yet when this will be resolved? I have a similar problem which may be the same. My launcher is set to use:

Code: Select all

Virtual Machine Parameters=-Xmx25:256:1024P
On some machines, usually ones with 4Gb+ of RAM the launcher fails to run with same error as above; even though there may be 3Gb of RAM available.

I thought that maybe this was due to memory fragmentation but, since seeing the above post, maybe not!? In any event, even if there is not enough contiguous memory available; at least when using the Percentage option, I think the launcher should try successively smaller (-32Mb) increments for maximum until successful; or outright failure. Setting the max to 920Mb for example works fine.

As a workaround I will read a custom property off the command line in the installer which will allow the user to specify the max memory if the installation fails the first time round. (There are certain things for which my installation package executes java applications using the native launcher, which upon failing cause the installation to abort and rollback; The rollback is desired!)

Other than that I have so far enjoyed using this product and it totally kicks InstallAnywhere's ASS!

GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact:  Website

Re: JNI Exception: Failed to create the Java VM

Thu Jan 14, 2010 2:34 pm

Hello,

We have improved the mechanism through which you can specify the heap size for your Java Product. You can now expect an increase of about a couple hundred MBs.
We will continue to improve it along future versions of Advanced Installer.

Also, the amount of physical memory is only useful as an indicator of system performance. You must make sure that the maximum limit is supported by the target OS.
I think the launcher should try successively smaller (-32Mb) increments for maximum until successful; or outright failure.
Thank your for your suggestion, we will take this into consideration for implementing in a future version of Advanced Installer.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/

Kumaravel
Posts: 6
Joined: Wed Oct 15, 2008 12:48 am

Re: JNI Exception: Failed to create the Java VM

Sat Mar 13, 2010 6:41 am

This issue is really annoying. Some of our customers are also having this issue. We don't know about new customers trying demo version of our product.
We used Advanced Installer version 7.5.

Is this issue fixed in version 7.5 ?

GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact:  Website

Re: JNI Exception: Failed to create the Java VM

Mon Mar 15, 2010 2:22 pm

Hello,

What is the quantity of memory you are trying to set for your VM? Also, what is the maximum quantity that works?

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/

jasons2645
Posts: 12
Joined: Mon Aug 03, 2009 10:57 pm

Re: JNI Exception: Failed to create the Java VM

Wed Apr 07, 2010 8:53 pm

Attempting to launch the JVM with 32MB increments less each time is a great idea. It would help us out too. Has this already been done by any chance?

snies
Posts: 2
Joined: Thu May 03, 2012 1:12 am

Re: JNI Exception: Failed to create the Java VM

Thu May 03, 2012 1:19 am

I too am having this problem. I can create installers containing up to 1024M. Specifying any value greater than 1024M causes the launcher to display the message "JNI exception: Failed to create the Java VM. Reason: not enough memory" even though the computer has several G of physical memory.

This bug is becoming critical for my client, in that he is delaying commercial release until the app can run with more memory. Any solutions / workarounds would be greatly appreciated!

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: JNI Exception: Failed to create the Java VM

Thu May 03, 2012 3:19 pm

Hi,

In order to set higher values for JVM heap size you could:
1) Use a 64-bit java product (or Any CPU if you want to support also 32-bit os).
2) Another approach would be to set different values for JVM heap size depending on what operating system your application runs because Windows Vista and newer Windows versions allow higher JVM heap sizes than Windows XP.

Please let me know what solution is suitable for you so I can give you more details.

Regards,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

snies
Posts: 2
Joined: Thu May 03, 2012 1:12 am

Re: JNI Exception: Failed to create the Java VM

Thu May 03, 2012 10:38 pm

Daniel,

Thank you for your quick reply. I did some more testing and discovered that the problem is indeed a launcher issue. I manually edited the app.ini file and progressively increased the "-Xmx" value until the app would no longer launch. The largest value that works on my XP machine is "-Xmx1355M". I also had my client perform the same test on his Vista machine. The largest value he could specify is "-Xmx1982M".

In your email you mentioned that different OSes allow different heap sizes - why is this the case? I would assume that, Java being Java, would have the same limit regardless of OS flavor. In any case why is the limit so low regardless of the installed physical RAM (my client's Vista machine has 10G memory installed)?

So I guess my questions are:

1) What is the maximum limit per each OS, assuming a 64 bit JVM?
2) Is there any workaround to let me increase the memory to, say, 4G?

Thank you again for your help,

Steve

Daniel
Posts: 8237
Joined: Mon Apr 02, 2012 1:11 pm
Contact:  Website

Re: JNI Exception: Failed to create the Java VM

Mon May 07, 2012 9:59 am

Hi Steve,
In your email you mentioned that different OSes allow different heap sizes - why is this the case? I would assume that, Java being Java, would have the same limit regardless of OS flavor.

Please keep in mind that JVM is reserving the entire heap as a contiguous memory block and its maximum size is affected by the fragmentation of the memory space. So, I assume newer operating systems like Windows Vista and Windows 7 behave better in this regard. The physical RAM is irrelevant because even if there is a smaller amount, the OS can compensate using virtual memory, thus allowing a 32-bit process to address up to the theoretical maximum value of 2GB.
1) What is the maximum limit per each OS, assuming a 64 bit JVM?
For 64-bit java products this limit is affected by the amount of physical and virtual system memory. I've managed to use up to 25 GB on a Win 7 64-bit with 16 GB of phisical memory and another 16 GB of virtual memory.
2) Is there any workaround to let me increase the memory to, say, 4G?

You should use a 64-bit java product and make sure that the target machine has more than 4 GB of total memory.

Regards,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”