aboutsummaryrefslogtreecommitdiffstats
path: root/includes/services
diff options
context:
space:
mode:
authorTim Starling <tstarling@wikimedia.org>2018-08-31 13:05:32 +1000
committerDaniel Kinzler <daniel.kinzler@wikimedia.de>2018-09-03 16:36:32 +0000
commitdaee97fb6b36b04b968456ef724166491681d583 (patch)
tree6599f72f8932837dd362c704e53bd3bca0c09077 /includes/services
parente2671b8fae63a4dd2a2b7c2df4b8a759095dd4f5 (diff)
downloadmediawikicore-daee97fb6b36b04b968456ef724166491681d583.tar.gz
mediawikicore-daee97fb6b36b04b968456ef724166491681d583.zip
Reduce memory usage on ServiceContainer destruction
The closures in ServiceContainer::$serviceInstantiators are circular references which prevent destruction of the object. So, delete these when destroy() is called. Also delete the service instances for good measure. Change-Id: Ic8487cb533a09a8fcc69eba4f5d1bbb71558ae08
Diffstat (limited to 'includes/services')
-rw-r--r--includes/services/ServiceContainer.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/includes/services/ServiceContainer.php b/includes/services/ServiceContainer.php
index 30f82955c53b..d934d270e44b 100644
--- a/includes/services/ServiceContainer.php
+++ b/includes/services/ServiceContainer.php
@@ -100,6 +100,12 @@ class ServiceContainer implements DestructibleService {
}
}
+ // Break circular references due to the $this reference in closures, by
+ // erasing the instantiator array. This allows the ServiceContainer to
+ // be deleted when it goes out of scope.
+ $this->serviceInstantiators = [];
+ // Also remove the services themselves, to avoid confusion.
+ $this->services = [];
$this->destroyed = true;
}