incubator-ooo-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 120078] When opening a docx file, there is a lot of leaks on property strings stored in OOXMLPropertySetImpl
Date Mon, 25 Jun 2012 08:30:39 GMT
https://issues.apache.org/ooo/show_bug.cgi?id=120078

--- Comment #1 from zhang jianfang <zhangjf@apache.org> ---
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.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Mime
View raw message