【发布时间】:2023-03-11 16:31:01
【问题描述】:
这是内存泄漏吗?
private void Process()
{
for (; ; )
{
// local variable
RemoteClient remoteClient = new RemoteClient(..);
// subscription without unsubscription
remoteClient.BadClient += new EventHandler(remoteClient_BadClient);
}
..
}
public class RemoteClient
{
...
public event EventHandler BadClient;
}
【问题讨论】:
-
否(如果 remoteClient 没有在其他地方引用)但它似乎没用,因为 remoteClient 将被 GC-ed 并且您的处理程序永远不会被调用。
标签: c# memory-leaks .net-3.5 garbage-collection