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

Removed WeakReference<IHosts> already cleaned up by GC #4995

Merged
merged 2 commits into from
Apr 4, 2020
Merged
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions src/Microsoft.ML.Core/Environment/HostEnvironmentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,14 @@ public HostBase(HostEnvironmentBase<TEnv> source, string shortName, string paren
Depth = source.Depth + 1;
}

/// <summary>
/// This method registers and returns the host for the calling component. The generated host is also
/// added to <see cref="_children"/> and encapsulated by <see cref="WeakReference"/>. It becomes
/// necessary to remove these hosts when they are reclaimed by the Garbage Collector.
/// </summary>
public new IHost Register(string name, int? seed = null, bool? verbose = null)
{
_children.RemoveAll(r => r.TryGetTarget(out IHost _) == false);
mstfbl marked this conversation as resolved.
Show resolved Hide resolved
Contracts.CheckNonEmpty(name, nameof(name));
IHost host;
lock (_cancelLock)
Expand Down