Friday, May 22, 2009

dbms_xmldom. Memory leak. createXMLCharacterInputStream, closeCharacterInputStream

Oracle 11.1.0.7 Std. Linux.

I have such a code.

procedure ...(a_node dbms_xmldom.domnode,a_text in out nocopy CLOB)
...
as
BEGIN
dt2 := dbms_xmldom.getChildNodes(a_node);
dt3 := dbms_xmldom.item(dt2,0);


stream_id := dbms_xmldom.createXMLCharacterInputStream(dt3.id);
...
LOOP
...
dbms_xmldom.readCharacterInputStream (stream_id,
buffer,
num_chars,
false);
...
END LOOP;
dbms_xmldom.closeCharacterInputStream(stream_id);
dbms_xmldom.freeNode(dt3);

END;

Under havy workload my db instance crashes, - being killed by Linux VM OOM killer. Yes, - Out of memory.

Let's Ask Bom!

Memory leaks under tags qmxdsjniAlloc(68 and 28 bytes) and qmxCreateMemCtx(20 bytes) - Yes ?

dbms_xmldom.createXMLCharacterInputStream (creation call)
qmxdsplsnode_createXMLCIS (C)
{
...
qmxdsGetPullNodeAsCharacterStream(...)
{
...
OraStreamInit(...) ---> memory allocation inside!!!
OraStreamOpen(...)
}
}

dbms_xmldom.closeCharacterInputStream (free call)
qmxdsplsnode_closeStream (C)
{
OraStreamClose(...)
}

Where is OraStreamTerm ?!!! ;))
i patched qmxdsplsnode_closeStream - add OraStreamTerm call.
Now it like watch ;)

No comments:

Post a Comment