Issue 113600

Summary: sw: MLK, sub table causes all table objects leak when loading text document
Product: Writer Reporter: zhang jianfang <zhangjf>
Component: codeAssignee: andreas.martens
Status: CLOSED FIXED QA Contact: issues@sw <issues>
Severity: Trivial    
Priority: P2 CC: issues, zhangjf
Version: OOO320m19   
Target Milestone: 4.0.0   
Hardware: All   
OS: All   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---
Issue Depends on:    
Issue Blocks: 120975    
Attachments:
Description Flags
sample file to recreate the memory leak
none
fix code patch none

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,

	swmi!SwXMLTableContext::InsertRow+0000010E
(z:\writ\sw\source\filter\xml\xmltbli.cxx, 1699)
	swmi!SwXMLTableRowContext_Impl::SwXMLTableRowContext_Impl+000002C5
(z:\writ\sw\source\filter\xml\xmltbli.cxx, 922)
	swmi!SwXMLTableContext::CreateChildContext+00000242
(z:\writ\sw\source\filter\xml\xmltbli.cxx, 1472)
	xomi!SvXMLImport::startElement+000004BD (z:\lib\xmloff\source\core\xmlimp.cxx, 700)
	sax.uno!sax_expatwrap::SaxExpatParser_Impl::callbackStartElement+000000F9
	sax.uno!XML_Parse+00001AFE
	sax.uno!XML_Parse+000020C8
	sax.uno!XML_ParseBuffer+00000037
	sax.uno!XML_Parse+000001A7
	sax.uno!sax_expatwrap::SaxExpatParser_Impl::parse+00000074
	sax.uno!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)
	sfxmi!SfxObjectShell::LoadOwnFormat+00000127
(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)
	fwkmi!framework::LoadEnv::impl_loadContent+00000C9A
(z:\lib\framework\source\loadenv\loadenv.cxx, 1210)
	fwkmi!framework::LoadEnv::startLoading+0000014A
(z:\lib\framework\source\loadenv\loadenv.cxx, 431)
	fwkmi!framework::LoadEnv::loadComponentFromURL+0000011A
(z:\lib\framework\source\loadenv\loadenv.cxx, 226)
	fwkmi!framework::Desktop::loadComponentFromURL+00000E4B
(z:\lib\framework\source\services\desktop.cxx, 775)
	msci_uno!bridges::cpp_uno::shared::UnoInterfaceProxy::getCppI+0000002F


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.