Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mono.Android] fix potential leak in Java.Lang.Thread #8900

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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