Page 1 of 1

java/lang/OutOfMemoryError

Posted: Wed May 17, 2023 5:23 pm
by Bravoj
We upgraded to a new version of Oracle and because of that we had to upgrade our JDBC driver from ojdbc14.jar (1.4) to ojdbc8.jar. we are now getting this error below. IBM is saying we need to use the 64 bit ojdbc8.jar. Any thoughts?


From IBM
we are running java 8 32 bit JVM and specifying a maximum heap of 2GB. they recommend we switch to 8 64 bit driver and increase heap to 4GB.
they also say this is Oracle's problem which I find hard to believe since we are using JAVA on the AS400.

Error:
JVMDUMP039I Processing dump event "systhrow", detail "java/lang/OutOfMemoryError" at 2023/05/16 03:24:57 - please wait.

Re: java/lang/OutOfMemoryError

Posted: Wed May 17, 2023 6:03 pm
by Scott Klement
Not the 64-bit jar.... the 64-bit Java runtime... (The jar is the same in either case.)

The 64-bit environment supports much more memory because 32-bit addresses can only address up to 4gb of memory maximum, whereas 64-bit addresses can support nearly 2 exabytes.

Re: java/lang/OutOfMemoryError

Posted: Wed May 17, 2023 11:56 pm
by Bravoj
Thank you , worked.

Re: java/lang/OutOfMemoryError

Posted: Thu May 18, 2023 2:50 pm
by Bravoj
Sorry Scott, when I said it worked that was in test but when I placed the code in production it failed on the same error OutOfMemory. This is what I placed in my CL before I call the RPG

ADDENVVAR ENVVAR(JAVA_HOME) VALUE('/QOpenSys/QIBM/ProdData/JavaVM/jdk80/64bit') REPLACE(*YES)
ADDENVVAR ENVVAR(CLASSPATH) VALUE('/java/jdbc/ojdbc8.jar') REPLACE(*YES)
call RPG

is this correct or what am I missing?

Re: java/lang/OutOfMemoryError

Posted: Mon May 22, 2023 4:08 am
by Scott Klement
You can try increasing the amount of memory that's available to Java to see if that helps.

From a PASE command line, type the following:

Code: Select all

java -XX:+PrintFlagsFinal -version | grep HeapSize
On my system, it prints this:

Code: Select all

   size_t MaxHeapSize                              = 2147483648      
What this tells me is the most memory that Java will allow is 2gb on my system (unless I tell it otherwise.) Based on that I might decide to tell it to allow more memory.

For example, I could define:

Code: Select all

  ADDENVVAR ENVVAR(QIBM_RPG_JAVA_PROPERTIES) VALUE('-Xms4096M;-Xmx6144M;')
This sets the initial heap size to 4gb (4096 mb) and the maximum to 6gb (6144 mb). This needs to be done before the JVM is loaded in the job (the same as the the CLASSPATH and JAVA_HOME).

I don't know if this will help (it strikes me as very strange that 2gb isn't enough... but maybe your Java settings are different) but please bear in mind that none of this has anything to do with my code -- it is basic Java setup. And it is the Oracle driver that is using the memory, not my programs... so I'm not really an expert, here.

At any rate, it's worth a try.

Re: java/lang/OutOfMemoryError

Posted: Tue May 23, 2023 1:42 pm
by Bravoj
thank you Scott, I will try this tonight.

Re: java/lang/OutOfMemoryError

Posted: Thu May 25, 2023 4:51 pm
by Bravoj
Scott, you suggestion below worked to increase the heap size. Thank you for all your help.



ADDENVVAR ENVVAR(QIBM_RPG_JAVA_PROPERTIES) VALUE('-Xms4096M;-Xmx6144M;')