I think this might not be sufficient. What if you discard an object that other objects (still) depend on? It would probably not be destroyed if the others still hold references. We might need to also destroy dependants.