I don't really think stdio is the place to see modern D ref counting. The container class has an Array which is built to use RefCounted. I had tried my and at explaining how to use it: http://stackoverflow.com/ questions/4632355/making-a-reference-counted-object-in-d-using- refcountedt/4635050#4635050
I'm not really sure if all the details have been worked out. Hopefully I explained it correctly and that it gives you an idea of how to make ref counting work.