Beef icon indicating copy to clipboard operation
Beef copied to clipboard

[Bug] Append allocation results in falsely detected memory leak

Open aharabada opened this issue 4 years ago • 0 comments

In the following example the string that has been added to "MyList" will be detected as a memory leak after a few seconds eventhough it's not actually a leak. Replacing the append allocation with a "normal" allocation will not be detected as a leak.

class MyClass
{
	List<String> MyList;

	[AllowAppend]
	public this()
	{
		let list = append List<String>();

		MyList = list;

		MyList.Add(new String("Hello"));
	}

	public ~this()
	{
		for(let str in MyList)
		{
			delete str;
		}

		delete:append MyList;
	}
}

class Program
{
	static int Main(String[] args)
	{
		MyClass c = new MyClass();

		for(;;){}

		delete c;
		return 0;
	}
}

aharabada avatar Feb 11 '21 17:02 aharabada