import std.c.stdlib; import std.stdio; import std.gc; class Wrapper { int *foshizzle; this ( ) { this.foshizzle = cast(int *)malloc( 1024 ); } ~this ( ) { free( this.foshizzle ); writefln("~Wrapper"); } } void do_something( inout Wrapper bar ) { bar = bar; } void main ( ) { Wrapper foo = new Wrapper( ); do_something( foo ); delete foo; std.gc.fullCollect( ); writefln("main"); } /* as above: jim@panicroom:~/test$ ./test ~Wrapper main //fullcollect: jim@panicroom:~/test$ ./test ~Wrapper main //delete: jim@panicroom:~/test$ ./test main ~Wrapper //delete + //fullcollect: jim@panicroom:~/test$ ./test main ~Wrapper RESULT: I win. ;P */