While I agree that there might be a bit of XY under the question, the problem is not because garbage collection does not happen soon enough. Since the closure (the sub reference in *One::foo) holds the $self scalar, the reference count never falls down to 0, so even if stevieb's program ran for a longer period of time, the object would not be garbage collected. Your solution though, by deleting the sub at the end of the scope also happens to delete its hold over the reference, which makes the deletion of the object possible.
In reply to Re^2: Trying to DESTROY() an object
by Eily
in thread SOLVED: Trying to DESTROY() a (closure-wrapped) object
by stevieb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |