byond - Modules - Types

code/controllers/subsystem/garbage.dm

Debugging GC issues

In order to debug qdel() failures, there are several tools available. To enable these tools, define TESTING in _compile_options.dm.

First is a verb called "Find References", which lists every refererence to an object in the world. This allows you to track down any indirect or obfuscated references that you might have missed.

Complementing this is another verb, "qdel() then Find References". This does exactly what you'd expect; it calls qdel() on the object and then it finds all references remaining. This is great, because it means that Destroy() will have been called before it starts to find references, so the only references you'll find will be the ones preventing the object from qdel()ing gracefully.

If you have a datum or something you are not destroying directly (say via the singulo), the next tool is QDEL_HINT_FINDREFERENCE. You can return this in Destroy() (where you would normally return ..()), to print a list of references once it enters the GC queue.

Finally is a verb, "Show qdel() Log", which shows the deletion log that the garbage subsystem keeps. This is helpful if you are having race conditions or need to review the order of deletions.

Note that for any of these tools to work TESTING must be defined. By using these methods of finding references, you can make your life far, far easier when dealing with qdel() failures.

/datum/qdel_itemQdel Item: Holds statistics on each type that passes thru qdel Holds the type as a string for this type Total number of times it's passed thru qdel. Total amount of milliseconds spent processing this type's Destroy() Times it was queued for soft deletion but failed to soft delete. Different from failures because it also includes QDEL_HINT_HARDDEL deletions Total amount of milliseconds spent hard deleting this type. Highest time spent hard_deleting this in ms. Number of times hard deletes took longer than the configured threshold Number of times it's not respected force=TRUE Number of times it's not even bother to give a qdel hint Number of times it's slept in its destroy

Flags related to this type's trip thru qdel.

/proc/qdel Should be treated as a replacement for the 'del' keyword.