Running a game server - need more memory - java

Its actually a Minecraft server. I have 16GB of RAM on my desktop here running a 4 core processor each core at 3.0ghz speed and 4GB Video Memory. its a pretty beefy computer (especially back in the day) yet it is still able to hold its own as a gaming computer even today running some pretty awesome games from Xboxone and whatever.
Well, I'm trying to run a game server on this desktop (I know it can handle it). Problem is, the server runs, but I can't see any of the mobs (NPC's creators of the world) on the map yet I can hear them. I know they are there. I can hear them. I go around my map, hearing them, but not seeing them.
I looked in other places on the web regarding this issue and found the issue is a memory issue (not enough memory). So I need to increase the memory of Java 8--problem is, it says in my server console "Ignoring max memory--support removed in 8.0" meaning though I set the memory in the bat file to run the server, it is ignoring how much I am telling it to use to run my server... and this is annoying.
Okay there is more details.
I entered a command in the server /memory
The server reports that the max memory allocated to the server is only a mere 1GB!!!! and I'm like WHAT!? Cuz I know I know I KNOW I have WAY more than that to offer my server! I need to increase that! So this is the issue.
To sum it up: Java 8 says it does not support max memory or min memory anymore if I were to set it up in a bat file to use 10,000MB (10GB) for my server when I run it--it ignores that... yet I need to force it to USE THAT AMMOUNT. how do I do this?
In control panel I already set it in the java, java tab, (field that is already there by default).
So I'm not sure what else to do.
Seems to me it was dumb of Java to remove support for memory heap customization in 8, makes me miss Java 7 if you ask me.
So any idea how I can make this work?

Make sure your java arguments include -Xmx and -Xms.
Read this question/answer for further details: What are the Xms and Xmx parameters when starting JVMs?

Related

How do I properly limit JVM's memory usage?

I've been stuck on my problem for quite some time. To give you a litte context, I have written a bot in Java and was planning to run it on a Raspberry Pi 3 Model A+ 24/7. To my surprise, when I tested the almost finished program, its memory consumption kept on rising indefinitely.
Soon I realised, I had to limit the memory usage which I looked up on several sites over the past couple months. Unfortunately, most of them are outdated (2013 and older) and the very few newer ones didn't cover the important changes which must have taken place because I'm not able to figure out why my issue is still occurring.
I've tried so many things over such a long period of time that I'm not sure if I'll be able to sum up all the things I've tried so far but will update this post if I remember some important details.
Please see the pictures of my last test with the following settings:
java -Xmx4m -Xms4m -Xss64k -XX:MaxMetaspaceSize=8m -jar bot.jar
As you see the memory was not limited and rose to the point where the process was killed shortly after. In some of my previous tests I used an empty while(true) loop because I don't think I have a memory leak in my program. Weirdly enough, the empty loop also increased the memory size very slowly but did also not decrease over time.
At this point I'm not sure if the JVM is even capable of having a specified memory limit. My code uses the Robot class to make screen captures and fire certain buttons in nested while loops which also remind the garbage collector to cue a collection with System.gc(). Do I also have to use the following argument for the JVM?
-XX:MaxDirectMemorySize
I'm really confused with all the changes on Java as well. I've tried a few different JDKs because I thought that might solve the problem. The last test was compiled with the JDK 14 and runs on Java 11. Do I need to configure something on the OS in order to limit the memory consumption?
Maybe you guys could also recommend me a profiler with which I can check what is even allocating the memory in order to figure out what needs to be limited via the arguments but I would definitely need some help because I have never worked with one before.
I appreciate any help on this topic! Please let me know if you need any additional information and I will do my best to follow up during the week.
Maybe you can use the following args : -XX:+PrintGCDetails -Xloggc:/tmp/jvm-gc.log. It will log gc details in /tmp/jvm-gc.log .
Or you can check the size of the runtime heap with the following command:
# get the pid
ps -aux | bot.jar
# show the heap info
jmap -heap <pid>

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

I tried to make a Minecraft Server, using the suggestions I've seen people telling others to use the Paper API. So I got all the files, and I allocated 512 MB of ram to it (using -Xmx512M), and it runs completely fine! But it bumps into the limit of RAM too much, so I tried to push it to 3 GB (using -Xmx3G). (A bit excessive, for what I'm using it for, but it'll help me sleep at night, knowing I have a server that's not running into issues) but then I run into the problem where Java simply does not want to start.
I experimented a bit, found that anything higher than 1.5G and Java starts having problems. Could not reserve enough space for 3145728KB object heap
.
So I went looking around, and found people saying "Add an Environment Variable to the System Variables with _JAVA_OPTIONS and -Xmx3G" and whatever, and it appears to not change anything for me. Java still doesn't want to start. Does anyone know how this is? I can't seem to update my Java to any higher version, assuming mine was outdated. So it can't be an update, and not everyone runs into this issue because a server manager once told me their server ran with 10GB of ram.
I'd ask them, but I've lost contact, so I'm asking here instead.
You may be using a 32-bit Java installation. Check which Java is being executed and install/use the 64-bit version.
https://java.com/en/download/manual.jsp
Make sure you're running 64 Bit Java. Otherwise, go to the link above and get the Windows 64-Bit Offline download. then run that. Immediately fixed it for me.

How can I see what my java program is using memory for?

I wrote a program that used to work fine but at one point in time it startet to lag malfunction and become very slow. I thought it had to do because it was connected to a distant MySQL server and no longer to the localhost server it had been running on before. (that change happened around the same time)
So today I decided I want to test out if I could revert the change and connected it back to the server running in localhost only to find that it didn't change a thing. I even had to end the program with the task manager.
At this point I saw that my program was using over 2GB of RAM and 44% of the cpu, which before was around 60MB and 1%. I have no idea why and I would like to find out and look deeper into the memory usage of my program other than just the total amount. Is there a way I can check what the memory is used for in a way a human can understand?

Webstart application fails to start with -Xmx2G on Java 8u60

I have a Java Webstart application that starts successfully with -Xmx1G, but fails to start with -Xmx2G. Some of my users really need 2G of heap.
This seems to be a problem with Java 8u60 only, because I have a report of someone launching successfully with Java 8u51.
The failure looks like this: I see the blue 'Java...' splash screen, and then after a few seconds, poof it's gone, before displaying the Java console and without producing any trace information in the expected place.
The failure occurs only on those clients with less than 2G of memory available. But, I am a little surprised that requesting a 'maximum' heap size could cause the application to fail so early and without any diagnostic information. We are dealing with a 'maximum' value, after all, not an 'initial' value. I read in multiple places that the JVM is not supposed to do this.
But I also remembered reading that the 'initial', if unspecified, is based on the maximum. So, along with passing -Xmx2G, I tried passing -Xms512M, -Xms256M, and -Xms128M. But, this attempt to shrink the initial heap size did not help. I cannot get this thing to start with -Xmx2G!
Does anyone have any light to shed on this situation? A solution? A workaround? In the short term, I'll change to -Xmx1G, but, as I said at the beginning, I have some users that really need -Xmx2G. I'd like to avoid having two separate *.jnlp files, which would also entail having two separate *.jar files!
Turns out that this is exactly what Webstart on Java8u60 does if the client machine does not have enough memory to satisfy -Xmx. It attempts to start, and then poof, it disappears without any indication as to what went wrong.
So, I will end up having to build my application in different configurations if I want to enable the users with more memory to allocate that memory to my application. This is because signing requires the *.jnlp file to into the *.jar file itself, and this *.jnlp file must be an exact match with the *.jnlp file used to launch the application.

java.lang.OutOfMemoryError: Java heap space running applet

I'm developing a graphic user interface with NetBeans IDE 7.0.1. I need to operate with long Strings (about 1 GB) and I've changed the start up configuration parameter to:
-J-Xss512M
-J-Xms4G
-J-Xmx12G
-J-XX:PermSize=4G
-J-XX:MaxPermSize=8G
When I execute the applet I receive the "java.lang.OutOfMemoryError: Java heap space" exception. I've checked th point of the exception and at that moment, the applet was trying to concatenate two Strings, one of them of 550.000.000 length and the other 68.000.000
If I change the parameters above, it changes nothing on the applet exception.
My computer has 16 GB RAm so I think this is not the problem. Maybe some applet configuration?
Can you help me?
Thanks a lot
What operating system are you running on? If its a 32 bit one you wont be able to address more than around 4G of RAM (less in practice, especially on a Windows machine).
The second point here is the config you're changing is, I think, for NetBeans - not for the applet. If so (and I'm not sure how this works in NetBeans) then you need to alter the memory settings for your Applet itself, not for NetBeans.
This is typically done via run configuration settings for the app/applet etc you're trying to run.
Hope this helps!

Categories

Resources