4

We had a situation where there really was insufficient memory for java, but no visible error was seen until the app was run with the -console option. Then we got an error on the console like:

Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap

The app is built with the "Fail if an exception in the main thread is thrown, but that does not appear to help. Configuration Image

java version "1.8.0_162"

Is there some other setting that can make such a memory error more visible?

Joel
  • 81
  • 1
  • As of install4j 7.0, there is no way to make this error message more visible, I've created an issue for it. – Ingo Kegel Aug 08 '18 at 15:05

1 Answers1

1

I am strongly suggest that you will add validation script in the startup or in the Welcomeenter image description here

Such validation script can validate what you want and can raise popup as shown in the example below (the example below check the Kernel and if the Kernel is not the required version than message raised with notification OS not supported): In your case change the logic to validate if there are enough memory.

String logfile = "/opt/ServiceStatus" + (String)context.getVariable("sys.version");
PrintWriter writer = new PrintWriter(new FileWriter(logfile, true));
String shellcommand = "uname -a";

Process p = Runtime.getRuntime().exec(shellcommand);
 p.waitFor();
 BufferedReader buf = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
String output = "";

while ((line = buf.readLine()) != null) 
{
    output += line + "\n";
}


if (!output.contains("3.10.0-514.el7.x86_64"))
{
    Util.showMessage("OS not suppurted");
    writer.println("OS not suppurted: " + output);
    writer.close();
    return false;
}    
writer.println("OS: " + output);
writer.close();
return true;
Oron Golan
  • 361
  • 1
  • 13
  • Typically memory use fluctuates, so testing memory on an install may give entirely different results than when the program runs. Especially with Java needing contiguous memory. This seems like a very partial solution. – Fred Andrews Aug 06 '18 at 14:43
  • In our case, the real customer problem was getting 1GB of memory on a 4GB physical memory computer. It was available right after a reboot, but not after other programs were running. So a run time solution, not an install time solution is what is needed. – Joel Aug 06 '18 at 18:49