Apache OpenOffice (AOO) Bugzilla – Issue 120029
[MemoryLeak]All GlobalAcceleratorConfiguration objects get leaked
Last modified: 2012-11-30 05:55:51 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.
Raise to a major problem. This in fact is a very serious problem, which cause many related objects get leaked too.
ModuleAcceleratorConfiguration class has almost same piece of code, so it may also have this kinds of memory leaks, will confirm it late.
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.
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 on attachment 78400 [details] patch for globalacceleratorconfiguration object leak problem Reviewed. Patch looks good.
Taking over for committing.
Committed. SVN revision is 1352075.
add MemoryLeak tag for this defect. This defect need Long running test to verify.
set release blocker flag for 3.4.1
Merged from trunk into 3.4.1 by revision r1356536.
set target milestone AOO 3.4.1
In last SVT(r1400866), no memory leak, so close this defect.