java/lang/OutOfMemoryError

Scott Klement's open source interface to using JDBC database drivers from RPG. http://www.scottklement.com/jdbc/
Post Reply
Bravoj
Posts: 9
Joined: Thu Jun 30, 2022 12:06 am

java/lang/OutOfMemoryError

Post 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.
Scott Klement
Site Admin
Posts: 702
Joined: Sun Jul 04, 2021 5:12 am

Re: java/lang/OutOfMemoryError

Post 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.
Bravoj
Posts: 9
Joined: Thu Jun 30, 2022 12:06 am

Re: java/lang/OutOfMemoryError

Post by Bravoj »

Thank you , worked.
Bravoj
Posts: 9
Joined: Thu Jun 30, 2022 12:06 am

Re: java/lang/OutOfMemoryError

Post 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?
Scott Klement
Site Admin
Posts: 702
Joined: Sun Jul 04, 2021 5:12 am

Re: java/lang/OutOfMemoryError

Post 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.
Bravoj
Posts: 9
Joined: Thu Jun 30, 2022 12:06 am

Re: java/lang/OutOfMemoryError

Post by Bravoj »

thank you Scott, I will try this tonight.
Bravoj
Posts: 9
Joined: Thu Jun 30, 2022 12:06 am

Re: java/lang/OutOfMemoryError

Post 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;')
Post Reply