Issue 113600 - sw: MLK, sub table causes all table objects leak when loading text document
Summary: sw: MLK, sub table causes all table objects leak when loading text document
Alias: None
Product: Writer
Classification: Application
Component: code (show other issues)
Version: OOO320m19
Hardware: All All
: P2 Trivial (vote)
Target Milestone: 4.0.0
Assignee: andreas.martens
QA Contact: issues@sw
Depends on:
Blocks: 120975
  Show dependency tree
Reported: 2010-08-03 04:25 UTC by zhang jianfang
Modified: 2017-05-20 10:32 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---

sample file to recreate the memory leak (37.92 KB, application/vnd.oasis.opendocument.text)
2010-08-03 04:28 UTC, zhang jianfang
no flags Details
fix code patch (448 bytes, patch)
2012-08-22 14:01 UTC, zhang jianfang
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description zhang jianfang 2010-08-03 04:25:46 UTC
If a text document has a sub table inside a main table, then all
table,subtable,rows/cols/row/col/cell context objects leaks when loading it. You
can reproduce the scenario with attached sample file.

Some of the leaked SwXMLTableRow_Impl objects are created with below call stack,

(z:\writ\sw\source\filter\xml\xmltbli.cxx, 1699)
(z:\writ\sw\source\filter\xml\xmltbli.cxx, 922)
(z:\writ\sw\source\filter\xml\xmltbli.cxx, 1472)
	xomi!SvXMLImport::startElement+000004BD (z:\lib\xmloff\source\core\xmlimp.cxx, 700)!sax_expatwrap::SaxExpatParser_Impl::callbackStartElement+000000F9!XML_Parse+00001AFE!XML_Parse+000020C8!XML_ParseBuffer+00000037!XML_Parse+000001A7!sax_expatwrap::SaxExpatParser_Impl::parse+00000074!sax_expatwrap::SaxExpatParser::parseStream+00000218
	swmi!ReadThroughComponent+000004D6 (z:\writ\sw\source\filter\xml\swxml.cxx, 233)
	swmi!ReadThroughComponent+00000526 (z:\writ\sw\source\filter\xml\swxml.cxx, 391)
	swmi!XMLReader::Read+00002814 (z:\writ\sw\source\filter\xml\swxml.cxx, 941)
	swmi!SwReader::Read+00000690 (z:\writ\sw\source\filter\basflt\shellio.cxx, 221)
	swmi!SwDocShell::Load+0000026D (z:\writ\sw\source\ui\app\docshini.cxx, 728)
	sfxmi!XLoadControlSO::DoLoad+0000004C (z:\lib\sfx2\source\doc\objstor.cxx, 330)
	sfxmi!XLoadControl::StartLoading+0000003A (z:\lib\sfx2\source\doc\objstor.cxx, 290)
(z:\lib\sfx2\source\doc\objstor.cxx, 3305)
	sfxmi!SfxObjectShell::DoLoad+00000743 (z:\lib\sfx2\source\doc\objstor.cxx, 858)
	sfxmi!SfxBaseModel::load+0000024A (z:\lib\sfx2\source\doc\sfxbasemodel.cxx, 1872)
	sfxmi!SfxFrameLoader_Impl::load+00002C11 (z:\lib\sfx2\source\view\frmload.cxx, 514)
(z:\lib\framework\source\loadenv\loadenv.cxx, 1210)
(z:\lib\framework\source\loadenv\loadenv.cxx, 431)
(z:\lib\framework\source\loadenv\loadenv.cxx, 226)
(z:\lib\framework\source\services\desktop.cxx, 775)

The root cause of the problem is that there cyclic refernce between sub table
SwXMLTableContext object and SwXMLTableContext.pRows->SwXMLTableRow_Impl
objects, which in sequence cause the main table objects are leaked too.
Comment 1 zhang jianfang 2010-08-03 04:28:40 UTC
Created attachment 70927 [details]
sample file to recreate the memory leak
Comment 2 zhang jianfang 2012-08-22 14:01:54 UTC
Created attachment 79071 [details]
fix code patch

The root cause of this leak is there are cyclic reference between sub table's SwXMLTableContext object and SwXMLTableContext.SwXMLTableRows_Impl.SwXMLTableRow_Impl object. The subtable object is not released, which in sequence causes the main table context object leaks too. For normal SwXMLTableContext object, the cyclic reference is broken when calling SwXMLTableContext.makeTable() api. For sub table, when SwXMLTableContext::MakeTable( SwTableBox *pBox, sal_Int32 nW )
is called, it doesn't has this behaviour.  So solution is to add the call to SwXMLTableRow_Impl.dispose() in SwXMLTableContext::MakeTable( SwTableBox *pBox, sal_Int32 nW ) too.
Comment 3 zhang jianfang 2012-08-22 14:02:50 UTC
Set target to AOO 3.5 and change to confirmed state.
Comment 4 SVN Robot 2012-09-04 02:05:48 UTC
"zhangjf" committed SVN revision 1380421 into trunk:
#i113600#, Add call to subtable SwXMLTableRow_Impl.dispose() to break cycle r...
Comment 5 zhang jianfang 2012-09-04 02:06:11 UTC
Comment on attachment 79071 [details]
fix code patch

Remove review tag since long time no response.
Comment 6 zhang jianfang 2012-09-04 02:06:51 UTC
Mark as resolved state.