Apache OpenOffice (AOO) Bugzilla – Full Text Issue Listing |
Summary: | When opening a docx file, there is a lot of leaks on property strings stored in OOXMLPropertySetImpl | ||||||
---|---|---|---|---|---|---|---|
Product: | Writer | Reporter: | zhang jianfang <zhangjf> | ||||
Component: | open-import | Assignee: | zhang jianfang <zhangjf> | ||||
Status: | CLOSED FIXED | QA Contact: | |||||
Severity: | Major | ||||||
Priority: | P3 | ||||||
Version: | 3.4.0 | ||||||
Target Milestone: | 4.0.0 | ||||||
Hardware: | All | ||||||
OS: | All | ||||||
Issue Type: | DEFECT | Latest Confirmation in: | --- | ||||
Developer Difficulty: | --- | ||||||
Issue Depends on: | |||||||
Issue Blocks: | 120975, 121359, 121372 | ||||||
Attachments: |
|
Description
zhang jianfang
2012-06-25 07:59:15 UTC
The cause is quite tricky, below explains why so many string objects get leaks, 1. In OOXMLFastContextHandlerProperties contructor it allocates OOXMLPropertySetImpl objects. Many OOXMLPropertyImpl contains OOXMLValue (Int, Object, Property...) then can be added into it by calling OOXMLPropertySetImpl::add() API. 2. The created OOXMLPropertyImpl object will be put into OOXMLFastContextHandlerProperties parent's OOXMLPropertySet by api OOXMLFastContextHandler::sendPropertiesToParent(). So OOXMLPropertySetImpl objects are orgnized in a reference tree. Once the root node leaks, all the tree node leak too. While the leak code point is far from where the leaked object created, void SettingsTable::lcl_sprm(Sprm& rSprm) { sal_uInt32 nSprmId = rSprm.getId(); Value::Pointer_t pValue = rSprm.getValue(); // here increase the ref count sal_Int32 nIntValue = pValue->getInt(); (void)nIntValue; rtl::OUString sStringValue = pValue->getString(); ... } it calls, Value::Pointer_t OOXMLPropertyImpl::getValue() { Value::Pointer_t pResult; if (mpValue.get() != NULL) pResult = Value::Pointer_t(mpValue->clone()); // mpValue may refer to a lot of OOXMLPropertySetImpl and other objects. else pResult = Value::Pointer_t(new OOXMLValue()); return pResult; } The direct cause of the memory leak is auto_ptr pValue in api SettingsTable::lcl_sprm() can not be released correctly. If you look deeper further, You will find the Value abstraction doesn't have a vitual destructor API. It means all it's subclass can not be freed correctly with the auto_ptr. Created attachment 78465 [details]
patch for file writerfilter/inc/resourcemodel/WW8ResourceModel.hxx
Add virtual destructor for classes Properties, Table, BinaryObj, Stream, Value and Sprm, so all shared_ptr, auto_ptr, reference<> to these classes can call correct sub-class destructors.
Comment on attachment 78465 [details]
patch for file writerfilter/inc/resourcemodel/WW8ResourceModel.hxx
Call for review.
|