?
Solved

ORA-29554 java out of memory condition

Posted on 2003-03-11
17
Medium Priority
?
1,203 Views
Last Modified: 2010-05-18
this procedure is cuasing the error in the title. i am trying to parse a 2mb xml file with a given xsl file which should produce a 20+mb xml file for insert into tables. my java_pool_size is set at 200mb. my java_maxsessionspace_size is also at 200mb. is there some other parameter i need to modify to avoid this error? can someone give me a guestimate on how much memory i should need? any other ideas as to the problem?  will you please look at this code and see if there is a problem with it that is causing a memroy leak or something? ask any questions. i appreciate the help.

ben

CREATE OR REPLACE PROCEDURE boxml_proc (
   p_xml_dir   VARCHAR2,
   p_xsl_dir   VARCHAR2,
   p_xmlfile   VARCHAR2,
   p_xslfile   VARCHAR2,
   p_resfile   VARCHAR2,
)
IS
   v_p             sys.xmlparser.parser;
   v_xmldoc        sys.xmldom.domdocument;
   v_xmldocnode    sys.xmldom.domnode;
   v_proc          sys.xslprocessor.processor;
   v_ss            sys.xslprocessor.stylesheet;
   v_xsldoc        sys.xmldom.domdocument;
   v_docfrag       sys.xmldom.domdocumentfragment;
   v_docfragnode   sys.xmldom.domnode;
   v_xslelem       sys.xmldom.domelement;
   c_nspace        VARCHAR2 (50);
   v_xslcmds       sys.xmldom.domnodelist;
BEGIN

--new parser
   v_p := sys.xmlparser.newparser;

--set characteristics
   sys.xmlparser.setvalidationmode (v_p, FALSE);
   sys.xmlparser.setpreservewhitespace (v_p, TRUE);
   sys.xmlparser.setbasedir (v_p, p_xml_dir);

-- parse xml file
   sys.xmlparser.parse (v_p,    p_xml_dir
                             || '/'
                             || p_xmlfile);

--get document
   v_xmldoc := sys.xmlparser.getdocument (v_p);

--parse xsl file
   sys.xmlparser.parse (v_p,    p_xsl_dir
                             || '/'
                             || p_xslfile);

--get document
   v_xsldoc := sys.xmlparser.getdocument (v_p);
   v_xslelem := sys.xmldom.getdocumentelement (v_xsldoc);
   c_nspace := sys.xmldom.getnamespace (v_xslelem);
   v_xslcmds := sys.xmldom.getchildrenbytagname (v_xslelem, '*', c_nspace);

--make stylesheet
   v_ss := sys.xslprocessor.newstylesheet (
              v_xsldoc,
                 p_xsl_dir
              || '/'
              || p_xslfile
           );

--process xsl
   v_proc := sys.xslprocessor.newprocessor;
   sys.xslprocessor.showwarnings (v_proc, TRUE);
   v_docfrag := sys.xslprocessor.processxsl (v_proc, v_ss, v_xmldoc);
   v_docfragnode := sys.xmldom.makenode (v_docfrag);
      sys.xmldom.writetofile (v_docfragnode,    p_xml_dir
                                          || '/'
                                          || p_resfile);
 sys.xmlparser.freeparser(v_p);
 sys.xmldom.freedocument(v_xmldoc);
 sys.xmldom.freedocument(v_xsldoc);
 sys.xslprocessor.freeprocessor(v_proc);
 sys.xslprocessor.freestylesheet(v_ss);

END;
/
0
Comment
Question by:benpung
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 8
17 Comments
 
LVL 1

Author Comment

by:benpung
ID: 8113556
i have also read that using the sax api is faster than using the dom api. however, i'm understanding that you cannot use sax if you are using xslt transformations as i am. is this true?
0
 
LVL 1

Expert Comment

by:PCBackup
ID: 8115876
Oracle does not offer any suggestions for this error code in the documentation, but when Oracle returns this error code, it should also return a line number to tell you which line caused the error.  Do you have that information available?  

It sure would make it easier to debug the problem, with all the calls to external routines.
0
 
LVL 1

Author Comment

by:benpung
ID: 8123160
well, the code doesn't always return an error. only when i try to parse large files. the code runs fine with smaller files. the error says that the xmlprocessorcover (or soemthing like that) at line 70 is causing the error. i believe that that happens to be the point where i run the memory dry.  what i really want if for people to look over this code and see if i am doing something wrong that is hogging up memory that is not necessary. any ideas? thanks.

ben
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:PCBackup
ID: 8130120
Well, nothing jumps right out at me, but this is a lot of XML routine calls to look through at one time.  You'll really need to find the specifics of that error message.  It is likely that you are fine through all the setup steps and the error occurs on the "big run" through the xslprocessor at this line...

   v_docfrag := sys.xslprocessor.processxsl (v_proc, v_ss, v_xmldoc);

This routine is within the right line range in my Oracle 9i version of this xml package, so I'm guessing that's your culprit.  But could you force the error again with a large file and verify the line number and package.  Once we verify this is the actual position of the error, then we can try to figure out if it is solveable.

My error log provides more than one program/package and line# in the log entry when my program calls another program/package that actually generates the error.  Oracle will show you all active calls outside of your program at the time of the error, and sometimes these can be nested a couple programs deep.

If you can, please get the entire log entry for this error to provide more clues, especially any reference showing the line number within your program.  Here's an example of an error I just forced to show my point...

00001  PROCEDURE testprog IS
00002    xyz number(6,2);
00003  BEGIN
00004    htp.print ('Running testprog...');
00005    xyz := 1/0;
00006  END;

00001  PROCEDURE testcallingprog IS
00002  BEGIN
00003    bz8x8c.testprog;
00004  END;

When testcallingprog is executed, the following error occurs, showing the entire error stack...

ORA-01476: divisor is equal to zero
ORA-06512: at "BZ8X8C.TESTPROG", line 5
ORA-06512: at "BZ8X8C.TESTCALLINGPROG", line 3

You can see that line 3 in testcallingprog was calling the routine in testprog, where I tried to divide by zero on line 5.  The original error message is important, but I need to know where the error relates to my code.  We need the same information for your error.

Gene
0
 
LVL 1

Author Comment

by:benpung
ID: 8136892
here is the entire error message that gets spit back at me when i run a large file:

ERROR at line 1:
ORA-29554: unhandled Java out of memory condition
ORA-29532: Java call terminated by uncaught Java exception:
java.lang.OutOfMemoryError
ORA-06512: at "SYS.XSLPROCESSORCOVER", line 0
ORA-06512: at "SYS.XSLPROCESSOR", line 70
ORA-06512: at "EMS_PROCS.BOXML_PROC", line 62
ORA-06512: at line 1

thanks for the help.
ben
0
 
LVL 1

Expert Comment

by:PCBackup
ID: 8139715
Could you now verify which line in your code is line 62?

Gene
0
 
LVL 1

Author Comment

by:benpung
ID: 8152711
line 62 is part of a quoted string in a dbms_output.put_line statement. wierd....
0
 
LVL 1

Expert Comment

by:PCBackup
ID: 8152933
In BOXML_PROC as shown in your original question, I do not see any dbms_output.put_line statements.  Are you looking in the correct procedure?  Does this procedure exist in more than one schema?  Have you modified it since the original question?  Are you possibly looking at the code that calls this boxml procedure instead of boxml itself?

Also, look at the procedure lines as stored in the Oracle schema object instead of any script file.  This line number may be different than one you see in a local editor window.  I examine the code for error line numbers using Oracle Procedure Builder's window.  

Could you copy the code from the general area of the line generating the error, especially if the code has changed since the original question.

I'll watch for your answer.

Gene
0
 
LVL 1

Author Comment

by:benpung
ID: 8167566
this is the entire procedure. sorry, i must have copied it incorrectly (or copied an old version). in my editor, the middle line in this block:
                     || p_resfile
                      || ' '
                      || p_reqid
the one with the '' is line 62. i'm not sure how to check for line 62 in the schema object as you suggest. can you do this with sqlplus? i know this isn't the right line but i don't know how to see it. thanks for the help.


CREATE OR REPLACE PROCEDURE boxml_proc (
   p_xml_dir     VARCHAR2,
   p_xsl_dir     VARCHAR2,
   p_xmlfile     VARCHAR2,
   p_xslfile     VARCHAR2,
   p_resfile     VARCHAR2,
   p_tablename   VARCHAR2,
   p_reqid       NUMBER
)
IS
   v_p             SYS.xmlparser.parser;
   v_xmldoc        SYS.xmldom.domdocument;
   v_xmldocnode    SYS.xmldom.domnode;
   v_proc          SYS.xslprocessor.processor;
   v_ss            SYS.xslprocessor.stylesheet;
   v_xsldoc        SYS.xmldom.domdocument;
   v_docfrag       SYS.xmldom.domdocumentfragment;
   v_docfragnode   SYS.xmldom.domnode;
   v_xslelem       SYS.xmldom.domelement;
   c_nspace        VARCHAR2 (50);
   v_xslcmds       SYS.xmldom.domnodelist;
BEGIN
--new parser
   v_p := SYS.xmlparser.newparser;
--set characteristics
   SYS.xmlparser.setvalidationmode (v_p, FALSE);
   SYS.xmlparser.setpreservewhitespace (v_p, TRUE);
   SYS.xmlparser.setbasedir (v_p, p_xml_dir);
-- parse xml file
   SYS.xmlparser.parse (v_p, p_xml_dir || '/' || p_xmlfile);
--get document
   v_xmldoc := SYS.xmlparser.getdocument (v_p);
--parse xsl file
   SYS.xmlparser.parse (v_p, p_xsl_dir || '/' || p_xslfile);
--get document
   v_xsldoc := SYS.xmlparser.getdocument (v_p);
   v_xslelem := SYS.xmldom.getdocumentelement (v_xsldoc);
   c_nspace := SYS.xmldom.getnamespace (v_xslelem);
   v_xslcmds := SYS.xmldom.getchildrenbytagname (v_xslelem, '*', c_nspace);
--make stylesheet
   v_ss :=
      SYS.xslprocessor.newstylesheet (v_xsldoc,
                                      p_xsl_dir || '/' || p_xslfile);
--process xsl
   v_proc := SYS.xslprocessor.newprocessor;
   SYS.xslprocessor.showwarnings (v_proc, TRUE);
   v_docfrag := SYS.xslprocessor.processxsl (v_proc, v_ss, v_xmldoc);
   v_docfragnode := SYS.xmldom.makenode (v_docfrag);
   SYS.xmldom.writetofile (v_docfragnode, p_xml_dir || '/' || p_resfile);
   SYS.xmlparser.freeparser (v_p);
   SYS.xmldom.freedocument (v_xmldoc);
   SYS.xmldom.freedocument (v_xsldoc);
   SYS.xslprocessor.freeprocessor (v_proc);
   SYS.xslprocessor.freestylesheet (v_ss);
   DBMS_OUTPUT.put_line (p_resfile);
   host_command_proc (   'ksh /home/ehsitdev/EIMS/batch/call_botables.ksh '
                      || p_tablename
                      || ' '
                      || p_xml_dir
                      || ' '
                      || p_resfile
                      || ' '
                      || p_reqid
                      || '',
                      'U+'
                     );
END;
/
0
 
LVL 1

Expert Comment

by:PCBackup
ID: 8168659
You can issue the following SQL*Plus command to view your entire code as Oracle stores it...

select line, text from user_source where name='BOXML_PROC' order by line;

This command requires you to type the procedure name in all capital letters because that's how Oracle stores the name in its object table, and the text may wrap at the end of the line, but you will be able to dump the procedure with the line numbers included this way.  Then we'll know which line is causing the error condition.

Or you can just go for the line you need and type...

select text from user_source where name='BOXML_PROC' and line=62;

I'll be waiting...

Gene
0
 
LVL 1

Author Comment

by:benpung
ID: 8169899
SQL> select text from user_source where name='BOXML_PROC' and line=62;

TEXT
--------------------------------------------------------------------------------
                      || ' '

this is what i get, the same thing i was being shown before. i get the same error if i take the call to host_command_proc out. it's wierd. any more thoughts? i think i'm going to look in to finding a different way to parse this thing. possbily use sax or something. this dom is a memory hog that has caused me nothing but trouble from day one. anyways, enough complaining. thanks.
0
 
LVL 1

Expert Comment

by:PCBackup
ID: 8173653
I wouldn't blame you for looking for a different method.  Is the error message you provided an up-to-date error?  Is it possible that it is really happening on a different line now?  It's important to make sure the code and the error message are in synch.  I agree that this error message does not make sense in the context of the code you have.

One possibility is that there is still a Java object that you have failed to "dispose" of to free memory usage.  It is possible that the error occurs when this routine tries to complete and exit, causing the error as a result of a failed object cleanup in Java.

Possibilities:

   v_xslelem
   v_xslcmds

Gene
0
 
LVL 1

Author Comment

by:benpung
ID: 8180157
i think you might be on to something with this idea. yes, the error is in sync with the code. it doesn't matter if i take that whole last host_command_proc statement out, i still get the same error. is there a way i should be freeing the v_xslemlem and v_xslcmds? thanks.
0
 
LVL 1

Accepted Solution

by:
PCBackup earned 100 total points
ID: 8180789
This is such a generic error message for java that the internet provides scores of possible causes for the problem.  Most responses to those problems suggest understanding the problem and solution method and determine if there is a way to perform the task in smaller chunks or increasing the memory in the Java Virtual Machine.  You didn't say if you had enough memory in your machine to further increase your java settings, but it might be useful to experiment with these settings increased further.  Oracle may not give all of the available memory specified to this single operation, and the two parameters may not work cooperatively.  The java_pool_size parameter may determine a lower limit on java_maxsessionspace_size, so don't assume these values will provide enough memory for your process.  If there is a java_maxsessions parameter, it might be used to calculate a lower limit than your stated maxsessionspace_size.  Take another look at the available java parameters to be sure you're getting what you think you asked for.

One internet document I found on this error message suggested they got the error when they tried to "free" the memory used by the XML document, and that sounds like a similar situation to yours.  However, they were not performing the XML operation in Oracle, but instead in regular JVM code.

Since I don't know anything about the XML and XSL files you are dealing with, and I don't know what the purpose behind the processing in your code, I'm not really able to tell you if you could approach the XSL problem from a different direction.  It appears you are using Oracle to work on local file system files, so it might be easier to perform this operation outside Oracle instead of within PL/SQL code.  You might also consider breaking the XSL transformation into smaller tasks and reassemble them after processing.  Finally, since it appears you are adding some type of formatting information that makes the file larger, try adding only portions of this extra content to the output to see if that affects the problem as well, using a modified XSL document.

It sounds like this problem can only be resolved with a different approach or a larger computer.  I don't think your basic code is the problem, but I do think the files involved are too large for this code to handle properly.

Gene
0
 
LVL 1

Author Comment

by:benpung
ID: 8197366
i think i need to look for an alternative solution. thanks for all your help.
0
 
LVL 1

Expert Comment

by:PCBackup
ID: 8202831
You're welcome.  Sorry I couldn't be more helpful.

Gene
0
 
LVL 1

Author Comment

by:benpung
ID: 8209703
i think you earned 25 pts just for the effort. thanks.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question