Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
GC the RuleTree when the Stylist is dropped.
We only consider doing a GC currently if the root node has a zero refcount.
But that only happens if it has no children -- even weak children keep a
strong reference to their parent.  So at the very least, we should do a
GC specifically when the RuleTree is going away.  (We probably want to add
some other GC opportunities too at some point, otherwise it's easy to
never GC a RuleTree.)
  • Loading branch information
heycam committed Nov 21, 2016
1 parent dd611ef commit 48aa707
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions components/style/stylist.rs
Expand Up @@ -624,6 +624,18 @@ impl Stylist {
}
}

impl Drop for Stylist {
fn drop(&mut self) {
// This is the last chance to GC the rule tree. If we have dropped all
// strong rule node references before the Stylist is dropped, then this
// will cause the rule tree to be destroyed correctly. If we haven't
// dropped all strong rule node references before now, then we will
// leak them, since there will be no way to call gc() on the rule tree
// after this point.
unsafe { self.rule_tree.gc(); }
}
}


/// Map that contains the CSS rules for a specific PseudoElement
/// (or lack of PseudoElement).
Expand Down

0 comments on commit 48aa707

Please sign in to comment.