/obj/test/proc/Kill()
del(src) // Delete all references to this object
/obj/test/Del()
loc = null // Null the only reference
..() // Will it still check even if I nulled out the only reference?
Problem description:
In the deconstructor I null out the only reference to the object. When Kill() is called, it will call the deconstructor via del(src) and then proceed to check for references.
When ..() is executed, will it efficiently check that there ARE references to null before looping for references and nulling them out? I was hoping by doing this I could optimize existing code to be friendly with the Garbage Collector.
Or will I have to create a separate proc which will make my object be garbage collected.
This means that the reference count hits zero as you state, but the VM doesn't need to act upon it yet.
The issue with del() is predominantly the need to reclaim memory, clean up appearance structures, inform the clients of the object's deletion, check references as you said etc. These are all things the VM will do anyway if the reference count hits zero, it's just del() forces the VM to do it right now, for one object.
Leaving the reference count as zero and not firing off del() yourself allows the VM to perform the operation at it's convenience, and if there are many such objects, in bulk. Meaning a more even CPU use spread because of deferred reclamation, a quicker reference check (per object), quicker resource writing to caches (per object) and better use of the network bandwidth to clients.
Your optimisation is pretty much not to call del() in this scenario or define your own destructor, and just let the VM take care of it.