theia icon indicating copy to clipboard operation
theia copied to clipboard

Memory leak due to DockPanelRenderer

Open Hanksha opened this issue 1 year ago • 0 comments

Bug Description:

The DockPanelRenderer in application-shell.ts listens to core preferences when creating a tab bar but never disposes of the listener (see here). The ToolBarAwareTabBar that it creates also never disposes of the TabBarToolrar. This leads to memory leak warnings when the user opens and closes a lot of tabs.

Steps to Reproduce:

  1. Open a file so it opens a tab.
  2. Close the file editor tab (there should be no tabs left open in the main editor area).
  3. Do that a good 200 hundred times (ideally via a playwright test)
  4. Check the logs, you'll see memory leak warnings related to listeners.

Example warning logs:

2024-01-26T13:37:10.345Z root WARN Possible Emitter memory leak detected. 176 listeners added. Use event.maxListeners to increase the limit (175). MOST frequent listener (1):
2024-01-26T13:37:10.345Z root WARN     at _event.Object.assign.maxListeners [as onDidChange] (http://localhost:3000/bundle.js:66811:54)    
    at TabBarToolbar.init (http://localhost:3000/bundle.js:53084:52)
    at _postConstruct (http://localhost:3000/bundle.js:95512:95)
    at _getInstanceAfterPostConstruct (http://localhost:3000/bundle.js:95499:31)
    at resolveInstance (http://localhost:3000/bundle.js:95544:16)
    at _getResolvedFromBinding (http://localhost:3000/bundle.js:95657:85)
    at http://localhost:3000/bundle.js:95675:22
    at _resolveInScope (http://localhost:3000/bundle.js:95669:14)

Additional Information

  • Operating System: Windows/Linux
  • Theia Version: 1.43.1

Hanksha avatar Jan 26 '24 13:01 Hanksha