Skip to content

Commit

Permalink
Merge branch 'main' into dev/grendel/native-tracing
Browse files Browse the repository at this point in the history
* main:
  [Mono.Android] fix potential leak of RunnableImplementors (#8900)
  • Loading branch information
grendello committed Apr 25, 2024
2 parents c9e5ebd + 3ce27c9 commit 8df0ef2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Mono.Android/Java.Lang/Thread.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

using Android.Runtime;
Expand Down Expand Up @@ -27,7 +28,7 @@ public RunnableImplementor (Action handler, bool removable)
this.removable = removable;
if (removable)
lock (instances)
instances [handler] = this;
instances.AddOrUpdate (handler, this);
}

public void Run ()
Expand All @@ -41,7 +42,7 @@ public void Run ()
Dispose ();
}

static Dictionary<Action, RunnableImplementor> instances = new Dictionary<Action, RunnableImplementor> ();
static ConditionalWeakTable<Action, RunnableImplementor> instances = new ();

public static RunnableImplementor Remove (Action handler)
{
Expand Down

0 comments on commit 8df0ef2

Please sign in to comment.