Fixed the most annoying GC issue ever
authorAlexander Ebert <ebert@woltlab.com>
Sat, 22 Oct 2016 15:10:49 +0000 (17:10 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 22 Oct 2016 15:10:57 +0000 (17:10 +0200)
wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php

index f19b72fdc9415d5be6029d1c6fd575516b98e671..bdcda157cf0f42e5c59554cf1e71f12c1911099b 100644 (file)
@@ -127,6 +127,13 @@ class HtmlInputNodeWoltlabMetacode extends AbstractHtmlInputNode {
                                }
                                
                                DOMUtil::replaceElement($element, $newElement);
+                               
+                               // We're explicitly throwing away the doc fragment, as any remaining
+                               // nodes will otherwise stick around for a while. They continue to exist
+                               // until `createElement` or `createDocumentFragment` are called which
+                               // cause an internal GC process that throws away the children, making
+                               // the end of their lifetime unpredictable. Thanks PHP.
+                               unset($fragment);
                        }
                        else {
                                // attributes are invalid, remove element from DOM