Error running Java application as SYSTEM using SCCM - java

I'm attempting to run a Desktop installer using Microsoft's SCCM. The installer was written using NSIS which predominantly executes Java calls. This works great unless it's run as the SYSTEM profile using SCCM. All Java calls look like this:
java -jar -Xms512m -Djna.nosys=true myapp.jar [options] ...
✅ When this application is run as a standard user, it works just fine.
⛔️ When this application is run as SYSTEM, it does not work.
Debugging this application we've found the following error is thrown:
Error occurred during initialization of VM
Unable to allocate 60928KB bitmaps for parallel garbage collection for the requested 1949696KB heap.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I've tried using the recommendations from this Harvard article, but then I get a new error.
java -jar -Xms512m -Djna.nosys=true -XX:+UseSerialGC -XX:ActiveProcessorCount=1 myapp.jar
# ^--- NEW ^--- NEW
The new error:
Java HotSpot(TM) 64-Bit Server VM warning: CodeCache is full. Compiler has been disabled.
Java HotSpException in thread "main" ot(TM) 64-Bit Server VM warning: Try increasing the code cache size using -XX:ReservedCodeCacheSize=
CodeCache: size=245760Kb used=3192Kb max_used=3192Kb free=242567Kb
bounds [0x00000295494c0000, 0x00000295497e0000, 0x00000295584c0000]
total_blobs=1238 nmethods=897 adapters=254
compilation: disabled (not enough contiguous free space left)
java.lang.OutOfMemoryError: Metaspace
Why won't Java run properly as SYSTEM using SCCM?

As a (non comprehensive) stop-gap solution, removing -Xms512m fixes the issue with SCCM. Fortunately the installer doesn't require as much memory as requested.

Related

Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit

I have changed the variable limit for java in environmental factors several times, I've adjusted maximum server ram usage in run.bat and still no luck.
Three different launches at different values include
C:\WINDOWS\system32>java -Xmx4000M -Xms512M -jar C:\Users\cavem\OneDrive\Desktop\RLCraft+Server+Pack+1.12.2+-+Beta+v2.8.2\forge-1.12.2-14.23.5.2854.jar nogui
Picked up _JAVA_OPTIONS: -Xmx4000M
Error occurred during initialization of VM
Could not reserve enough space for 4096000KB object heap
C:\WINDOWS\system32>java -Xmx4000M -Xms512M -jar C:\Users\cavem\OneDrive\Desktop\RLCraft+Server+Pack+1.12.2+-+Beta+v2.8.2\forge-1.12.2-14.23.5.2854.jar nogui
Picked up _JAVA_OPTIONS: -Xmx4100M
Invalid maximum heap size: -Xmx4100M
The specified size exceeds the maximum representable size.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
C:\WINDOWS\system32>java -Xmx4000M -Xms512M -jar C:\Users\cavem\OneDrive\Desktop\RLCraft+Server+Pack+1.12.2+-+Beta+v2.8.2\forge-1.12.2-14.23.5.2854.jar nogui
Picked up _JAVA_OPTIONS: -Xmx4000M
Error occurred during initialization of VM
Could not reserve enough space for 4096000KB object heap
If I give the program to much memory it doesn't start, if I give it to little it doesn't start. Any ideas as to what my problem may be? I changed the file to include complete location after receiving errors regarding not being able to find the file upon booting the server (running java and run.bat in administrator hasn't helped either).
Looks like you are using a 32-bit JVM, install a 64-bit JVM will work.

Error: could not create the Java Virtual Machine Can't allocate enough memory to Minecraft server

I have currently been trying to setup a minecraft server on an Intel Nuc that I have it has 8gb of ram this will be important later. I used to be running it on my main desktop and was able to tun it with 4gb of ram allocated to it, that computer had 16gb of ram though. My initial problem was that I could not allocated more than 1500M of ram to it using the following command in a .bat file;
java -Xms2048M -Xmx2048M -jar server.jar
I then decided to run it in command prompt and received the following error.
java -Xmx2048M -Xms2048M -jar server.jar nogui
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
I did some research on the error and found that I might need to add a system variable for.
Variable name: _JAVA_OPTIONS
Variable value: -Xmx512M
So I did that and it still didn't work.
Then I decided to install 64bit Java as I did not know if I had it or not and that is when I received the error;
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
So after that i tried to figure out which version I had so I ran the command;
java -version
and received this:
Picked up _JAVA_OPTIONS: -xms512M
Unrecognized option: -xms512M
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Whenever I try to run any Java commands or the server this is what I get and this is after I had removed the system variable.
I am not super knowledgeable about Java and I am just trying to run a minecraft server so if you need any more information please ask.
Thanks for all of the feedback but I got it working it turns out I just needed to restart a few times and uninstall the version of Java I had and get 64-bit Java. Also if your still curious I am running windows on the NUC

java on osx - xmx ignored?

i've got two computers running on Mac OS X El Capitan and Ubuntu 16.04 LTS. On both is Java SDK 1.8.0_101 installed.
When I try to start an game server on Ubuntu with more memory than available, I get the following output:
$ java -Xms200G -Xmx200G -jar craftbukkit.jar nogui
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00007f9b6e580000, 71582613504, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 71582613504 bytes for committing reserved memory.
# An error report file with more information is saved as:
#
On Mac OS I don't get this error:
$ java -Xms200G -Xmx200G -jar craftbukkit.jar nogui
Loading libraries, please wait...
Both computers have 8GB of memory. I also tried with an other Apple computer - same problem.
Is that a bug of java mac version?
(Is there a way to force limit the memory usage e.g. to 1GB? -Xmx1G won't work and I wasn't able to find another reason. Not here neither on google)
Thank you!
Sorry for my bad english...
It's a difference in how the operating systems work. Linux has a concept of a 'fixed' swap - this is based on physical RAM + the various swapfiles/swap partitions added to the system. This is considered the maximum limit of memory that can be committed.
OSX doesn't consider swap as fixed. It will continue to add swapfiles as more and more memory is committed on the operating system (you can see the files being added in /var/vm).
As a result, you can ask OSX for significantly more memory than is available and it will effectively reply with 'ok', while under linux it will go 'no'.
The upper-bound limit is still enforced by java - once the heap goes above the size specified it will return a java.lang.OutOfMemoryError: Java heap space exception, so if you're specifying a -Xmx1G then it should be enforced by the JRE.
You can see the difference with a simple test program:
import java.util.Vector;
public class memtest {
public static void main(String args[]) throws Exception {
Vector<byte[]> v = new Vector<byte[]>();
while (true) {
v.add(new byte[128 * 1024]);
System.out.println(v.size());
}
}
};
If this program is run with -Xmx100M it dies with a Java heap space message after ~730 iterations, when run with -Xmx1G it dies with a Java heap space message after ~7300 iterations, showing that the limit is being enforced by the java virtual machine.

Eclipse: "Could not reserve enough space"

So I'm doing a minecraft mod in java in eclipse and any time I wanted to start it in eclipse for testing it doesn't work and I get the following output:
Error occurred during initialization of VM
Could not reserve enough space for 1048576KB object heap
Java HotSpot(TM) Client VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
What can I do? Obviously this problem is not about the RAM not being there, I've got 6GB, it's about java not being allowed to take it.

Setting Java Heap Size does not work with 256GB RAM 64-bit machine

I have been trying to find the answer to this but I still could not.
I have a 64-bit machine with 256 GB RAM.
I am trying to execute a Java program which links to MySQL. And it needs a quiet big heap size because when I used VM argument -Xmx1024m after few minutes this pops up:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
But, when I tried to set the program VM argument by -Xmx2048m or bigger, it does not work and said:
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
I read that setting -Xmx2048 is not a problem for 64-bit machine but I really do not know why it's not working on my machine.
java -version output:
wmic OS get FreePhysicalMemory /Value output:
FreePhysicalMemory=251663664
wmic computersystem get TotalPhysicalMemory output:
TotalPhysicalMemory
274811621376
wmic os get osarchitecture output
OSArchitecture
64-bit
I could not execute systeminfo|find "Memory" as it says wrong syntax. Im not sure why either.
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
This message implies the java heap does not have enough space to do further allocation.
It seems you have set to 1G of Xmx which is insufficient for your application
else the application might leak memory which occupies space in java heap.
Error occurred during initialization of VM
Could not reserve enough space for 2097152KB object heap
During VM initialization. JVM does various init right from Heap to JIT modules.
Java heap are continiuos space while doing doing initialization if JVM could not find the
contigous memory space for the requested Xmx then above error message will be thrown.
These are virtual memory allocation so please do not confuse with physical memory values
Please run the command
java -verbose:init -Xmx2048 -version
this command will tell the steps undergoes by JVM while doing initialization and during what step it got failed.
Consider running your app as an administrator - just launch the PowerShell console via right click -> Run as Administrator.
Windows may deny granting a lot of memory to a single process that is running non-elevated.
Also - are you using Windows Server or a workstation version of Windows? It is generally recommended to use Windows Server for such "big" services.

Categories