develooper Front page | perl.perl5.porters | Postings from August 2013

Reliable global destruction?

Thread Next
From:
Leon Timmermans
Date:
August 18, 2013 17:44
Subject:
Reliable global destruction?
Message ID:
CAHhgV8ja070OySoBkvEt-Z9vN=Y_mA617-NPBBXs6nq3R67Cxg@mail.gmail.com
Currently, global destruction is a (mostly) two phase: objects and
then non-objects. In the first phase, objects are destroyed in random
order, so any destructor had to take this into account. In many cases,
that means that the destructor skips itself when global destruction is
going on because it can't know if any object it depends on is still
alive, this is rather unfortunate for a variety of reasons. But what
if we did support reliable global destruction?

How? By first doing a topological sort[1] of the object graph, and
then destroying them root-up. There are some caveats there: it doesn't
handle hard loops and fieldhashes are a bit tricky too (though I think
that's fixable). And then there are objects created during global
destruction…

Still, I'm fairly certain the situation can be made a lot more sane
than it currently is. I'm just not sure what the runtime cost of this
would be. I can only imagine it being more than a mark-and-sweep
garbage collection cycle, but then again it's only done once.

Leon

1: https://en.wikipedia.org/wiki/Topological_sort

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About