java.lang.OutOfMemoryError: Java heap space running applet - java

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!

Related

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.

Running a game server - need more memory

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?

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.

Some `jar` files do not run in Windows 7

We have bunch of jar files that are Java applications and run just fine. There are a few however that do nothing although it is expected to run :) with a GUI.
Is this a common issue with jar files that some have difficulties to run?
The OS is Windows 7 and the example not working jar is whitebox a free GIS application, BTW.
We reiterate that we have many jar applications that run like a charm in the above system. This means that it should not be a problem with Java installation (latest update 7u40 exists in the system).
We checked almost all jar failure related topics but no one discussing the issue above which is happening for some applications.
We also mention, we uninstalled and reinstalled java many times but with no success. The application whitebox does nothing. In one try, it did run and when we closed it. And we are since then trying to run it again but nothing is happening! Even nothing appears in the running Processes!
We examined command line and double click. No success. The file type association is correct. Furthermore as we said others are working just fine.
The problem reported was due to inadequate RAM. Whitebox requires 2GB RAM to run smoothly. While this is huge we could run it on an old laptop with only 1GB RAM. The solution was to increase the size of paging file (virtual memory) into the range 1024MB and 2048MB. We also moved its location from C drive into other drives. We the settings mentioned it runs without any problem. We have tried it many times and happy to report for this case the problem is now completely solved.
Conclusion:
For some Java applications if something happend as described in the question it may be due to memory requirement. In this case increasing virtual memory could solve the problem without a need to buy additional RAM.

Java applet white screen

I'm trying to get to the bottom of a problem with our Java applet based program. It quite regularly seizes up with an unresponsive GUI (or a white screen). This of course only happens when deployed at a customer site :-(. They are running a version of the Sun JVM in 1.5 series (not sure the exact release).
We have a theory that it's to do with the applet running out of heap space - does that sound plausible? The other thing that I have set up on my machine is disabling direct draw, but that was mainly to avoid weird artefacts on other applications.
They are seeing the problem on Citrix and on regular PCs, but obviously there is a limit to what the users on Citrix can do.
Any suggestions?
Running out of heap space should cause an OutOfMemoryError to be thrown. This case sounds like a typical deadlock. To find where that is you want a stack dump of all the threads. IIRC< you can do it through the console, or from IIRC 1.6 the JDK includes jps and jstack.
First of all ensure the customer uses the latest release of the JVM they are using, and make them enable the Java console inside their browser (this requires some research from you).
Then when it happens again, tell them to look at the console window and cut-paste the contents in a mail to you.
In order to solve the problem, you must first be able to reproduce the problem. You will need an identical system in order to troubleshoot this, making one change at a time while keeping everything else equal to determine the cause(s).
Just to add to this answer (to build the knowledge base as I'm currently looking into this).
There's (at least) 2 distinct white screens related to applets.
Deadlock (as mentioned by Tom) - area will not refresh when you drag a window in front of it, so you get the strange tails left effect.
VM crash - area will become white, Java VM closes (search for hs_err_pid*.log, location dependent on browser)

Categories

Resources