[ObjCRuntime] Fix a GCHandle leak. (#10981)

Make sure to free the weak GCHandles we create to track NSObjects, just
removing them from our dictionary doesn't cut it.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
This commit is contained in:
VS MobileTools Engineering Service 2 2021-03-31 14:58:28 -07:00 коммит произвёл GitHub
Родитель d0069abd4a
Коммит 4ba01d16f3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -997,8 +997,10 @@ namespace ObjCRuntime {
{
lock (lock_obj) {
if (object_map.TryGetValue (ptr, out var wr)) {
if (managed_obj == null || wr.Target == (object) managed_obj)
if (managed_obj == null || wr.Target == (object) managed_obj) {
object_map.Remove (ptr);
wr.Free ();
}
}