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;

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.

  • Just guessing, are you running 32bit or 64bit version of the database? – ibre5041 May 15 '15 at 11:47
  • The database is 64 bit – sjk May 15 '15 at 11:55
  • Then I'm afraid it is best to contact Oracle support. Or try to use Oracle 12c, 11g still uses JVM 1.5. – ibre5041 May 15 '15 at 12:00
  • What's the code in the procedure causing the out of memory error? – Colin 't Hart May 15 '15 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.