carymrobbins / intellij-haskforce

Haskell plugin for IntelliJ IDEA
http://carymrobbins.github.io/intellij-haskforce/
Apache License 2.0
485 stars 41 forks source link

Memory leak detected for ConsoleViewImpl #417

Open carymrobbins opened 4 years ago

carymrobbins commented 4 years ago

Reproducible by -

  1. Run the ide task via gradle (ideally from IntelliJ).
  2. From the newly spawned IntelliJ instance, open a Haskell project with a configured external tool (e.g. ghc-mod)
  3. Confirm the Haskell Tools Console has output from an external tool
  4. Close the project, then close the spawned IntelliJ.
  5. Check the stack trace produced from the gradle process.
java.lang.RuntimeException: Memory leak detected: 'com.intellij.execution.impl.ConsoleViewImpl[,29,0,1329x333,invalid,layout=java.awt.BorderLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]' of class com.intellij.execution.impl.ConsoleViewImpl
See the cause for the corresponding Disposer.register() stacktrace:

    at com.intellij.openapi.util.ObjectTree.assertIsEmpty(ObjectTree.java:225)
    at com.intellij.openapi.util.Disposer.assertIsEmpty(Disposer.java:137)
    at com.intellij.openapi.util.Disposer.assertIsEmpty(Disposer.java:132)
    at com.intellij.openapi.application.impl.ApplicationImpl.disposeSelf(ApplicationImpl.java:182)
    at com.intellij.openapi.application.impl.ApplicationImpl.doExit(ApplicationImpl.java:655)
    at com.intellij.openapi.application.impl.ApplicationImpl.exit(ApplicationImpl.java:628)
    at com.intellij.openapi.application.impl.ApplicationImpl.exit(ApplicationImpl.java:617)
    at com.intellij.openapi.application.impl.ApplicationImpl.exit(ApplicationImpl.java:613)
    at com.intellij.openapi.application.impl.ApplicationImpl.exit(ApplicationImpl.java:584)
    at com.intellij.openapi.application.impl.ApplicationImpl.exit(ApplicationImpl.java:579)
    at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame$3.windowClosing(WelcomeFrame.java:108)
    at java.desktop/java.awt.AWTEventMulticaster.windowClosing(AWTEventMulticaster.java:357)
    at java.desktop/java.awt.AWTEventMulticaster.windowClosing(AWTEventMulticaster.java:357)
    at java.desktop/java.awt.Window.processWindowEvent(Window.java:2079)
    at java.desktop/javax.swing.JFrame.processWindowEvent(JFrame.java:298)
    at java.desktop/java.awt.Window.processEvent(Window.java:2038)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5026)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
    at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2773)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4858)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:908)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:781)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:424)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:698)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:423)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.lang.Throwable
    at com.intellij.openapi.util.ObjectNode.<init>(ObjectNode.java:35)
    at com.intellij.openapi.util.ObjectTree.createNodeFor(ObjectTree.java:106)
    at com.intellij.openapi.util.ObjectTree.register(ObjectTree.java:70)
    at com.intellij.openapi.util.Disposer.register(Disposer.java:78)
    at com.intellij.util.Alarm.<init>(Alarm.java:140)
    at com.intellij.execution.impl.ConsoleViewImpl.<init>(ConsoleViewImpl.java:94)
    at com.intellij.execution.impl.ConsoleViewImpl.<init>(ConsoleViewImpl.java:150)
    at com.intellij.execution.filters.TextConsoleBuilderImpl.createConsole(TextConsoleBuilderImpl.java:58)
    at com.intellij.execution.filters.TextConsoleBuilderImpl.getConsole(TextConsoleBuilderImpl.java:49)
    at com.haskforce.ui.tools.HaskellToolsConsole.newConsole(HaskellToolsConsole.scala:114)
    at com.haskforce.ui.tools.HaskellToolsConsole.$anonfun$getConsole$1(HaskellToolsConsole.scala:106)
    at scala.collection.MapLike.getOrElse(MapLike.scala:128)
    at scala.collection.MapLike.getOrElse$(MapLike.scala:126)
    at scala.collection.AbstractMap.getOrElse(Map.scala:59)
    at com.haskforce.ui.tools.HaskellToolsConsole.getConsole(HaskellToolsConsole.scala:106)
    at com.haskforce.ui.tools.HaskellToolsConsole.$anonfun$write$1(HaskellToolsConsole.scala:57)
    at com.haskforce.utils.SAMUtils$$anon$4.run(SAMUtils.scala:14)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:309)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.doRun(LaterInvocator.java:441)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.runNextEvent(LaterInvocator.java:424)
    at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:407)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
    ... 11 more
2019-12-31 16:14:25,708 [  25200]  ERROR - api.util.objectTree.ObjectTree - IntelliJ IDEA 2019.3.1  Build #IC-193.5662.53 
2019-12-31 16:14:25,709 [  25201]  ERROR - api.util.objectTree.ObjectTree - JDK: 11.0.5; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o 
2019-12-31 16:14:25,709 [  25201]  ERROR - api.util.objectTree.ObjectTree - OS: Mac OS X 
2019-12-31 16:14:25,709 [  25201]  ERROR - api.util.objectTree.ObjectTree - Plugin to blame: HaskForce 
carymrobbins commented 4 years ago

I've attempted to resolve this in the 417-mem-leak-ConsoleViewImpl branch by refactoring to use a ProjectComponent so that the console fields get disposed on project close, but that doesn't seem to have helped and the stack trace is still produced.