debugging java.lang.OutOfMemoryError

We seem to have a java memory leak in our PL/SQL code somewhere. We must have a newXYZ without a freeXYZ or something because we're getting:

"ORA-29532: Java call terminated by uncaught Java exception: java.lang.OutOfMemoryError."

The problem is in a queue payload processing program. It uses AQ to dequeue an object containing a message type and an XML clob, parses the clob, processes it depending on the payload message type, and optionally creates another XML message for another queue.

I've reviewed the code in detail and have not found the source of the problem. Is there some trick to find out where the memory leak is occurring?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Helena Markováprogrammer-analystCommented:
You can search this site
for "java.lang.OutOfMemoryError". Maybe it will help you.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

i am the one that started the thread you reference in your link. freeing up my parsers and documents helped, but i'm still having the problem. what am i limited by as far as setting my own session memory with the setmaxmemorysize procedure referenced in the link? am i limited by the java_pool_size param? the java_max_session_size param? i cannot seem to get through this parsing process w/o the memroy error. any addional info would help. thanks.

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

rkogelheAuthor Commented:
Thanks Lucy, the major problem was that the DOM docs where not freed. It wasn't obvious that they required a free.
I take it that in general, all XDK objects must be freed? Why do you think Oracle does not free objects when they loose context?
Does this change in 9i2? If not, I still think we need to find a mechanism for finding or spotting memory leaks.
Where is the java memory for a user process? I tried looking at the PGA and UGA and it does not seem to be there. Is it in the SGA?
Are there any stats (i.e. v$sesstat) that can display its growth?
Can oradebug be used to find a leak?
I still seem to have a leak of some sort. The process runs in a SNP process and the process's resident memory keeps growing.
rkogelheAuthor Commented:
I still don't see a good solution to this problem. I suspect we still have a memory leak as the SNP processes are consuming more an more memory.

Is there not a standard java class that can be used to diagnose memory problems?
rkogelheAuthor Commented:
Ok, I found a solution I think:

-- create in SYS

import java.lang.*;

public class Runtime {
  public static long freeMemory () {
    long free = Runtime.getRuntime().freeMemory();
    return free;

show errors java source Runtime

    NAME 'FactoryRuntime.freeMemory() return long';

With this, you can log the size of java memory before and after function calls. This is not definitive, because there seems to be some discrepency how much memory is allocated for each call, but you can see when a significant amount of java memory is consumed without being freed.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.