Friday, May 22, 2009

dbms_xmldom. Possible Memory leak.LpxInitEncoded0

Oracle 11.1.0.7 Std Linux.

And Bom Said...
While processing XMLType code flows thr LpxInitEncoded0 func.
This function is extended wrapper for XmlCreateNew func with settupping MemManagerFuncs structure as task.

LpxInitEncoded0(...)
{

MemManagerFuncs* p1;
if(...)
{
p1 = OraMemInit(...,qmxsaxAllocMem, qmxSaxFreeMem);
}
else
{
//My DB now using this way
p1 = 0;
}
XmlCreateNew(...,p1,...);
...
}

memory management funcs recived thr p1 would be used for all allocs and frees during parsing XMLType.
Let's detail it.

qmxsaxAllocMem()
{
allocs memory from Oracle heaps
}

qmxSaxFreeMem
{
empty! ;))
}

You saying: "Baby tt's simple - garbage collector". May be, but why Oracle LPX fanatically calls it ?
Using qmxsaxAllocMem and qmxSaxFreeMem funcs inside LPX have another limitation, Oracle could not initialize XMLType for documents with tags(nodes) above 32M(Limitation of Oracle heaps).

I solve both troubles by calling XmlCreateNew with zero as address of MemManagerFuncs struct. In such case XmlCreateNew initializing it by self using simple malloc and free.
Two rabbits killed - no leaks and welcome big nodes.

No comments:

Post a Comment