zielu / GitToolBox

GitToolBox IntelliJ plugin
GNU General Public License v3.0
603 stars 71 forks source link

zielu.gittoolbox holds disposed project #512

Closed ViugiNick closed 7 months ago

ViugiNick commented 7 months ago

We received a few memory usage reports for Android Studio Iguana | 2023.2.1 Canary 14 showing these 2 lambdas holding references to already disposed projects. Unfortunately the names of the classes are obfuscated, but there should be a lambda where multiple arguments store Project as a field and retains if from being GCed. It leads to a memory leak. Projects are held for multiple hours.

Could you please take a look?

 55.0MB/1 objects          (root): com.intellij.util.concurrency.AppDelayQueue$TransferThread
    55.0MB/1 objects          this$0: com.intellij.util.concurrency.AppDelayQueue
    55.0MB/1 objects          q: java.util.PriorityQueue
    55.0MB/1 objects          queue: [Ljava.lang.Object;
    47.9MB/1 objects          []: com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask
    47.9MB/1 objects          callable: com.intellij.util.concurrency.ContextCallable
    47.9MB/1 objects          myCallable: java.util.concurrent.Executors$RunnableAdapter
    47.9MB/1 objects          task: zielu.gittoolbox.F.h$$Lambda$3466/0x0000000801f0b7f8
    47.9MB/1 objects          arg$3: zielu.gittoolbox.b.D(disposed)
    47.9MB/1 objects          a: com.intellij.openapi.project.impl.ProjectImpl(disposed)
    31.3MB/1 objects          +-_extensionArea$delegate: kotlin.SynchronizedLazyImpl
    31.3MB/1 objects          | _value: com.intellij.openapi.extensions.impl.ExtensionsAreaImpl
    31.3MB/1 objects          | extensionPoints: java.util.ImmutableCollections$MapN
    31.3MB/1 objects          | table: [Ljava.lang.Object;
    13.1MB/1 objects          \-componentStoreValue: com.intellij.util.concurrency.SynchronizedClearableLazy
    13.1MB/1 objects            computedValue: java.util.concurrent.atomic.AtomicReference
    13.1MB/1 objects            value: com.intellij.configurationScript.providers.MyProjectStore
97.9MB/1 objects          (root): com.intellij.util.concurrency.AppDelayQueue$TransferThread
    97.9MB/1 objects          this$0: com.intellij.util.concurrency.AppDelayQueue
    97.9MB/1 objects          q: java.util.PriorityQueue
    97.9MB/1 objects          queue: [Ljava.lang.Object;
    89.7MB/1 objects          []: com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask
    89.7MB/1 objects          callable: com.intellij.util.concurrency.ContextCallable
    89.7MB/1 objects          myCallable: java.util.concurrent.Executors$RunnableAdapter
    89.7MB/1 objects          task: zielu.gittoolbox.F.h$$Lambda$3466/0x0000000801f0b7f8
    89.7MB/1 objects          arg$4: zielu.gittoolbox.m.Y
    89.7MB/1 objects          a: com.intellij.openapi.project.impl.ProjectImpl(disposed)
    12.7MB/1 objects          componentStoreValue: com.intellij.util.concurrency.SynchronizedClearableLazy
    12.7MB/1 objects          computedValue: java.util.concurrent.atomic.AtomicReference
    12.7MB/1 objects          value: com.intellij.configurationScript.providers.MyProjectStore
zielu commented 7 months ago

Hi, I'll look into it.

zielu commented 7 months ago

Found it - it's related to per-project background tasks not being properly cancelled

zielu commented 7 months ago

Done in 500.0.23+222