Issue 120029 - [MemoryLeak]All GlobalAcceleratorConfiguration objects get leaked
Summary: [MemoryLeak]All GlobalAcceleratorConfiguration objects get leaked
Status: CLOSED FIXED
Alias: None
Product: General
Classification: Code
Component: code (show other issues)
Version: 3.4.0
Hardware: PC All
: P3 Major (vote)
Target Milestone: 3.4.1
Assignee: Andre
QA Contact:
URL:
Keywords:
Depends on:
Blocks: 120975 121359 121372
  Show dependency tree
 
Reported: 2012-06-19 05:54 UTC by zhang jianfang
Modified: 2012-11-30 05:55 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---
jsc: 3.4.1_release_blocker+


Attachments
patch for globalacceleratorconfiguration object leak problem (9.61 KB, patch)
2012-06-20 06:23 UTC, zhang jianfang
awf.aoo: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description zhang jianfang 2012-06-19 05:54:34 UTC
Simply open/close a document, if you track down the allocated GlobalAcceleratorConfiguration objects, you will find all are not freed finally.

The callstack where allocate the GlobalAcceleratorConfiguration object is at,

	ntdll!RtlUlonglongByteSwap+00000B52
	MSVCR90!malloc+00000079
	sal3!rtl_allocateMemory+0000000D (e:\aooblds\builds\r343539\sal\rtl\source\alloc_global.c, 301)
	fwk!cppu::OWeakObject::operator new+0000000C (e:\aooblds\builds\r343539\solver\340\wntmsci12.pro\inc\cppuhelper\weak.hxx, 90)
	fwk!framework::GlobalAcceleratorConfiguration::impl_createInstance+00000036 (e:\aooblds\builds\r343539\framework\source\accelerators\globalacceleratorconfiguration.cxx, 70)
	cppuhelper3MSC!cppu::OSingleFactoryHelper::createInstanceEveryTime+0000011E (e:\aooblds\builds\r343539\cppuhelper\source\factory.cxx, 179)
	cppuhelper3MSC!cppu::OSingleFactoryHelper::createInstanceWithContext+00000043 (e:\aooblds\builds\r343539\cppuhelper\source\factory.cxx, 211)
	cppuhelper3MSC!cppu::OFactoryComponentHelper::createInstanceWithContext+000000FE (e:\aooblds\builds\r343539\cppuhelper\source\factory.cxx, 495)
	cppuhelper3MSC!cppu::ORegistryFactoryHelper::createInstanceEveryTime+0000014B (e:\aooblds\builds\r343539\cppuhelper\source\factory.cxx, 759)
	cppuhelper3MSC!cppu::OSingleFactoryHelper::createInstanceWithContext+00000043 (e:\aooblds\builds\r343539\cppuhelper\source\factory.cxx, 211)
	cppuhelper3MSC!cppu::OFactoryComponentHelper::createInstanceWithContext+000000FE (e:\aooblds\builds\r343539\cppuhelper\source\factory.cxx, 495)
	bootstrap.uno!stoc_smgr::OServiceManager::createInstanceWithContext+0000033B (e:\aooblds\builds\r343539\stoc\source\servicemanager\servicemanager.cxx, 1246)
	bootstrap.uno!stoc_smgr::OServiceManager::createInstance+0000004B (e:\aooblds\builds\r343539\stoc\source\servicemanager\servicemanager.cxx, 1356)
	fwk!framework::ToolBarManager::RetrieveShortcut+0000055E (e:\aooblds\builds\r343539\framework\source\uielement\toolbarmanager.cxx, 2329)
	fwk!framework::ToolBarManager::FillToolbar+0000103B (e:\aooblds\builds\r343539\framework\source\uielement\toolbarmanager.cxx, 1376)
	fwk!framework::ToolBarWrapper::initialize+000004A4 (e:\aooblds\builds\r343539\framework\source\uielement\toolbarwrapper.cxx, 195)
	fwk!framework::MenuBarFactory::CreateUIElement+000008FD (e:\aooblds\builds\r343539\framework\source\uifactory\menubarfactory.cxx, 205)
	fwk!framework::ToolBoxFactory::createUIElement+000000F2 (e:\aooblds\builds\r343539\framework\source\uifactory\toolboxfactory.cxx, 96)
	fwk!framework::UIElementFactoryManager::createUIElement+0000022D (e:\aooblds\builds\r343539\framework\source\uifactory\uielementfactorymanager.cxx, 455)
	fwk!framework::ToolbarLayoutManager::implts_createElement+000001B5 (e:\aooblds\builds\r343539\framework\source\layoutmanager\toolbarlayoutmanager.cxx, 1368)
	fwk!framework::ToolbarLayoutManager::implts_createToolBar+0000013E (e:\aooblds\builds\r343539\framework\source\layoutmanager\toolbarlayoutmanager.cxx, 1278)
	fwk!framework::ToolbarLayoutManager::createToolbar+0000004F (e:\aooblds\builds\r343539\framework\source\layoutmanager\toolbarlayoutmanager.cxx, 455)
	fwk!framework::ToolbarLayoutManager::requestToolbar+0000021D (e:\aooblds\builds\r343539\framework\source\layoutmanager\toolbarlayoutmanager.cxx, 444)
	fwk!framework::LayoutManager::requestElement+000002F1 (e:\aooblds\builds\r343539\framework\source\layoutmanager\layoutmanager.cxx, 1716)
	sfx!SfxWorkWindow::UpdateObjectBars_Impl+00000479 (e:\aooblds\builds\r343539\sfx2\source\appl\workwin.cxx, 1508)
	sfx!SfxFrameWorkWin_Impl::UpdateObjectBars_Impl+0000004F (e:\aooblds\builds\r343539\sfx2\source\appl\workwin.cxx, 1357)
	sfx!SfxDispatcher::Update_Impl+0000049A (e:\aooblds\builds\r343539\sfx2\source\control\dispatch.cxx, 1733)
	sfx!SfxApplication::SetViewFrame_Impl+00000319 (e:\aooblds\builds\r343539\sfx2\source\appl\app.cxx, 529)
	sfx!SfxViewFrame::SetViewFrame+00000013 (e:\aooblds\builds\r343539\sfx2\source\view\viewfrm.cxx, 3547)
	sfx!SfxViewFrame::MakeActive_Impl+000000EE (e:\aooblds\builds\r343539\sfx2\source\view\viewfrm.cxx, 1983)
	sfx!SfxBaseController::ConnectSfxFrame_Impl+00000C28 (e:\aooblds\builds\r343539\sfx2\source\view\sfxbasecontroller.cxx, 1381)
	sfx!SfxBaseController::attachFrame+000001B0 (e:\aooblds\builds\r343539\sfx2\source\view\sfxbasecontroller.cxx, 638)



The reference which cause this object can not be freed is at, 

void GlobalAcceleratorConfiguration::impl_ts_fillCache()
{
    // get current office locale ... but dont cache it.
    // Otherwise we must be listener on the configuration layer
    // which seems to superflous for this small implementation .-)
	::comphelper::Locale aLocale = ::comphelper::Locale(m_sLocale);
    
    // May be there exists no accelerator config? Handle it gracefully :-)
    try
    {   
        m_sGlobalOrModules = CFG_ENTRY_GLOBAL;		
        XCUBasedAcceleratorConfiguration::reload();

		css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfg, css::uno::UNO_QUERY_THROW);
		xBroadcaster->addChangesListener(static_cast< css::util::XChangesListener* >(this));
    }
    catch(const css::uno::RuntimeException& exRun)
        { throw exRun; }
    catch(const css::uno::Exception&)
        {}
}

The listener will always keeps there without free.
Comment 1 zhang jianfang 2012-06-19 06:17:28 UTC
Raise to a major problem.

This in fact is a very serious problem, which cause many related objects get leaked too.
Comment 2 zhang jianfang 2012-06-19 06:33:57 UTC
ModuleAcceleratorConfiguration class has almost same piece of code, so it may also have this kinds of memory leaks, will confirm it late.
Comment 3 zhang jianfang 2012-06-20 06:23:18 UTC
Created attachment 78400 [details]
patch for globalacceleratorconfiguration object leak problem

The fix is to add XComponent interface implementation on XCUBasedAcceleratorConfiguration, it is inherited by both GlobalAcceleratorConfiguration and ModuleAcceleratorConfiguration.  Then call it's dispose() API in ToolbarManager, MenuBarManager and moduleuiconfigurationmanager's dispose() api.

Here ModuleAcceleratorConfiguration.dispose() is not critical because it is rarely called, but for constancy it is also implemented.
Comment 4 zhang jianfang 2012-06-20 11:32:49 UTC
This memory leak happens with very common use cases, includes when new/open a document it shows the toolbar, or mouse click to show the drop down menu...  Many GlobalAcceleratorConfiguration referenced objects also leak too. So propose it to be a 3.4.1 candidate.
Comment 5 Andre 2012-06-20 12:14:50 UTC
Comment on attachment 78400 [details]
patch for globalacceleratorconfiguration object leak problem

Reviewed.  Patch looks good.
Comment 6 Andre 2012-06-20 12:49:42 UTC
Taking over for committing.
Comment 7 Andre 2012-06-20 12:59:10 UTC
Committed.  SVN revision is 1352075.
Comment 8 Li Feng Wang 2012-06-26 07:04:58 UTC
add MemoryLeak tag for this defect.
This defect need Long running test to verify.
Comment 9 jsc 2012-07-02 13:22:12 UTC
set release blocker flag for 3.4.1
Comment 10 zhang jianfang 2012-07-03 01:20:39 UTC
Merged from trunk into 3.4.1 by revision r1356536.
Comment 11 jsc 2012-07-25 09:07:53 UTC
set target milestone AOO 3.4.1
Comment 12 Yan Ji 2012-11-30 05:55:51 UTC
In last SVT(r1400866), no memory leak, so close this defect.