mkbsc
mkbsc

Reputation: 107

How to see memory allocated to Oracle JVM

I am trying to execute some java code in Oracle JVM but getting java.lang.OutOfMemoryError.

so I want to dedicate more memory to Oracle JVM. How shuld we do that?

Thanks in advance.

Upvotes: 2

Views: 10465

Answers (3)

java-addict301
java-addict301

Reputation: 4136

The above suggestions didn't work for me. You can use

select getMaxMemorySize() from dual

To show this. You can then set it using:

create or replace function setMaxMemorySize(num number) return number
is language java name
'oracle.aurora.vm.OracleRuntime.setMaxMemorySize(long) returns long';

then calling this function:

select setMaxMemorySize(1024*1024*1024) from dual;

Note: This only sets the max memory for the session. You will need to call this for each new session.

Upvotes: 0

GWu
GWu

Reputation: 2787

Seems you are exceeding the heap size of the OJVM.

First you need to find out how much heap size you have available right now in total: Take a look at your initialization parameter JAVA_POOL_SIZE. If it is 0, then you are using automatic memory management (10g or 11g) and the heap size is determined by the Oracle server "automagically". Then you can take sga_target (10g) or memory_target (11g) as an upper limit.

The maximum heap size per session is limited by the parameter java_max_sessionspace_size (value 0 means default of 4GB).

With these two values at hand, take the smaller one and check if the memory requirements/heap size caused by your code should fit into this amount of memory.

  • If yes: you have a memory leak in your java code.
  • If not: increase either java_pool_size, sga_target/memory_target or java_max_sessionspace_size.

See http://docs.oracle.com/cd/B28359_01/java.111/b31225/chnine.htm#BABGFDAE (Java Memory Usage) and http://docs.oracle.com/cd/B28359_01/server.111/b28320/initparams099.htm#REFRN10074 + http://docs.oracle.com/cd/B28359_01/server.111/b28320/initparams100.htm#REFRN10075 (Parameters) for detailled documentation.

And regarding your question "How to see memory allocated to Oracle JVM" in the subject:

select * from v$sgastat where pool = 'java pool';

Upvotes: 5

Doru
Doru

Reputation: 91

You can use the http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html, specifically -XX:MaxHeapFreeRatio and -XX:MinHeapFreeRatio

Upvotes: 0

Related Questions