Beef icon indicating copy to clipboard operation
Beef copied to clipboard

Deleting an object that was detected as leaked

Open disarray2077 opened this issue 3 years ago • 0 comments

The code below causes the error mentioned in the issue title.

class ConsoleWrite
{
	private String mMsg = new .();

	public this(String msg)
	{
		mMsg.Set(msg);
	}

	public void ReturnValueDiscarded()
	{
		ThreadPool.QueueUserWorkItem(new [=]() =>
		{
			Console.Write(mMsg);
		} ~ delete mMsg);
		delete this;
	}
}

static ConsoleWrite ConsoleWrite(String msg)
{
	return new ConsoleWrite(msg);
}

public static void Main()
{
	while (true)
	{
		ConsoleWrite("Test\n");
	}
}

Tested with https://github.com/beefytech/Beef/commit/2b7d0284f7891b3d82e75f814ff90000d185a62d

disarray2077 avatar Sep 11 '22 19:09 disarray2077