Try adding: import core.memory : GC; Account[] children = new Account[n_children]; GC.addRoot(children.ptr); scope(exit) GC.removeRoot(children.ptr); With the GC turned on, does it still cause issues? Also are you compiling for 64bit or 32bit?