AtomMaterialUI / material-theme-issues

Issues Repository for the Material Theme UI plugin for JetBrains
Other
61 stars 4 forks source link

[Bug]: Retained disposed instances of com.mallowigi.idea.focusmode.MTFocusedElementHighlightingCaretListener hold 77mb #430

Closed ViugiNick closed 6 months ago

ViugiNick commented 9 months ago

Describe the bug

149 instances com.mallowigi.idea.focusmode.MTFocusedElementHighlightingCaretListener$2 are holding references to 149 disposed MTFocusedElementHighlightingCaretListener, which holds 149 editors(77mb)

58.9MB/1 objects          project: com.intellij.openapi.project.impl.ProjectImpl
49.9MB/1 objects          +-serviceInstanceHotCache: java.util.concurrent.ConcurrentHashMap
49.9MB/1 objects          | table: [Ljava.util.concurrent.ConcurrentHashMap$Node;
36.7MB/4 objects          | []: java.util.concurrent.ConcurrentHashMap$Node
2.07MB/1 objects          | +-val: io.flutter.view.FlutterView
 855KB/1 objects          | | busConnection: com.intellij.util.messages.impl.MessageBusConnectionImpl
 855KB/1 objects          | | bus: com.intellij.util.messages.impl.RootBus
  216B/1 objects          | | subscribers: java.util.concurrent.ConcurrentLinkedQueue
  192B/1 objects          | | head: java.util.concurrent.ConcurrentLinkedQueue$Node
81.0MB/1 objects   (rep)  | | next: java.util.concurrent.ConcurrentLinkedQueue$Node
78.1MB/151 objects        | | item: com.intellij.util.messages.impl.MessageBusConnectionImpl
78.1MB/151 objects        | | subscriptions: java.util.concurrent.atomic.AtomicReference
78.1MB/151 objects        | | value: [Ljava.lang.Object;
77.7MB/149 objects        | | +-[]: com.mallowigi.idea.focusmode.MTFocusedElementHighlightingCaretListener$2
77.7MB/149 objects        | | | this$0: com.mallowigi.idea.focusmode.MTFocusedElementHighlightingCaretListener(disposed)
77.6MB/149 objects        | | | editor: com.intellij.openapi.editor.impl.EditorImpl

According to the reporting the problem remained for ~13 hours and the number of retained disposed instances was increasing:

To Reproduce

Unfortunately we don't have exact steps to reproduce the issue, the bug is based on memory usage reports

Expected behavior

No memory leaks

Material Theme Version

no data

IDE

Android Studio

System Info

Iguana | 2023.2.1 Canary 14
Windows 11

Logs/Screenshots

No response

mallowigi commented 9 months ago

I've decided to remove this feature in the next versions of the plugin. Thanks for your support.

ViugiNick commented 9 months ago

@mallowigi Thanks! Also found cases where MTTabsPainterPatcherComponent$initComponent$2$3 is holding disposed projects:

[   15/ 88%/  240B]     280MB/1 objects          project: com.intellij.openapi.project.impl.ProjectImpl
[   15/ 88%/  240B]    90.0MB/1 objects          messageBus: com.intellij.util.messages.impl.CompositeMessageBus
[   15/ 88%/  240B]     860KB/1 objects          rootBus: com.intellij.util.messages.impl.RootBus
[   15/ 88%/  240B]      216B/1 objects          subscribers: java.util.concurrent.ConcurrentLinkedQueue
[   15/ 88%/  240B]      192B/1 objects          head: java.util.concurrent.ConcurrentLinkedQueue$Node
[   15/ 88%/  240B]     104MB/1 objects   (rep)  next: java.util.concurrent.ConcurrentLinkedQueue$Node
[   15/ 88%/  240B]    98.9MB/1 objects          item: com.intellij.util.messages.impl.MessageBusConnectionImpl
[   15/ 88%/  240B]    98.9MB/1 objects          subscriptions: java.util.concurrent.atomic.AtomicReference
[   15/ 88%/  240B]    98.9MB/1 objects          value: [Ljava.lang.Object;
98.9MB/15 objects          []: com.mallowigi.idea.tabs.MTTabsPainterPatcherComponent$initComponent$2$3
98.9MB/15 objects          $project: com.intellij.openapi.project.impl.ProjectImpl(disposed)

Could you please take a look

ViugiNick commented 8 months ago

@mallowigi One more path:

    141MB/17 objects            item: com.intellij.util.messages.impl.MessageBusConnectionImpl
    141MB/17 objects            subscriptions: java.util.concurrent.atomic.AtomicReference
    141MB/17 objects            value: [Ljava.lang.Object;
    24.3MB/1 objects            \-[]: com.mallowigi.idea.projectframe.MTTitleFrame$$Lambda$3456/0x0000000801eb52e8
    24.3MB/1 objects              arg$1: com.mallowigi.idea.projectframe.MTTitleFrame
    24.1MB/1 objects              project: com.intellij.openapi.project.impl.ProjectImpl(disposed)
mallowigi commented 8 months ago

Just so I understand, what is the right course of action to fix these issues?

-- Elior On 13 Dec 2023 at 18:10 +0200, ViugiNick @.***>, wrote:

@mallowigi One more path: 24.3MB/1 objects -[]: com.mallowigi.idea.projectframe.MTTitleFrame$$Lambda$3456/0x0000000801eb52e8 24.3MB/1 objects arg$1: com.mallowigi.idea.projectframe.MTTitleFrame 24.1MB/1 objects project: com.intellij.openapi.project.impl.ProjectImpl(disposed) — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

ViugiNick commented 8 months ago

It these cases it's worth checking what is the parrent disposable for the connections and why they remain in the subscriptions queue even when the corresponding project is disposed. I'm not entirely sure, but these handlers may be attached to something with a longer lifecycle then a project, but it this case it shouldn't store a reference to it.