From 0d2065e76c0eefaaaa184e7702d380c35ec0c115 Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 28 Sep 2017 11:37:10 -0700 Subject: [PATCH] (stable) When we purge the request cache, also force PHP to collect cycles Summary: Ref T12997. See that task for more details. Briefly, an unusual dataset (where commits are mentioned hundreds of times by other commits) is causing some weird memory behavior in the daemons. Forcing PHP to GC cycles explicitly after each task completes seems to help with this, by cleaning up some of the memory between tasks. A more thorough fix might be to untangle the `$xactions` structure, but that's significantly more involved. Test Plan: - Did this locally in a controlled environment, saw an immediate collection of a 500MB `$xactions` cycle. - Put a similar change in production, memory usage seemed less to improve. It's hard to tell for sure that this does anything, but it shouldn't hurt. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T12997 Differential Revision: https://secure.phabricator.com/D18657 --- src/applications/cache/PhabricatorCaches.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/applications/cache/PhabricatorCaches.php b/src/applications/cache/PhabricatorCaches.php index 1314aa4ccc..9c22bde672 100644 --- a/src/applications/cache/PhabricatorCaches.php +++ b/src/applications/cache/PhabricatorCaches.php @@ -51,6 +51,12 @@ final class PhabricatorCaches extends Phobject { */ public static function destroyRequestCache() { self::$requestCache = null; + + // See T12997. Force the GC to run when the request cache is destroyed to + // clean up any cycles which may still be hanging around. + if (function_exists('gc_collect_cycles')) { + gc_collect_cycles(); + } }