I have a Java stored procedure inside Oracle 11g database. The procedure uses lots of memory, so I'm setting the max memory size in same session:
create or replace function setMaxMemorySize(num number) return number is language java name 'oracle.aurora.vm.OracleRuntime.setMaxMemorySize(long) returns long'; / select setMaxMemorySize(4*1024*1024*1024) from dual;
I can confirm that max memory has been set:
create or replace function getMaxMemorySize return number is language java name 'oracle.aurora.vm.OracleRuntime.getMaxMemorySize() returns long'; / select getMaxMemorySize() from dual; 4294967295
However, when I run my Java procedure, I get out of memory error from PostgreSQL JDBC driver that the program is using
Exception in thread "Root Thread" org.postgresql.util.PSQLException: Ran out of memory retrieving query results. ... Caused by: java.lang.OutOfMemoryError
But the same program (with same arguments) runs fine outside database by setting the memory limit as JVM argument.
Why is setMaxMemorySize not working? Is there some other parameter I need to set? Java Pool size is already set to 5 GB.