xxxxxxxxxx
import core.lifetime:emplace;
import core.stdc.stdlib:malloc;
int foo(int)
{
auto mem = cast(Exception)malloc(__traits(classInstanceSize, Exception));
auto memo = emplace!(Exception,string)(mem, "HOHOH");
//scope b = a;
throw memo;
}
void test()
{
try
{
foo(1);
}
catch(Exception e)
{
}
}
void main()
{
import std.stdio;
import core.memory;
auto stats1 = GC.stats();
test();
auto stats2 = GC.stats();
writeln(stats1);
writeln(stats2);
}
/+
Output:
Stats(0, 0, 0)
Stats(1376, 1047200, 1360)
+/