From: Brion Vibber Date: Tue, 1 Jun 2010 20:53:44 +0000 (-0700) Subject: Fix memory leak in Inbox::addToInbox() (usage of raw DB_DataObject::staticGet, which... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=17ab15a3d02c335f2d9d333ac3773c037e796cf5;p=quix0rs-gnu-social.git Fix memory leak in Inbox::addToInbox() (usage of raw DB_DataObject::staticGet, which leaks memory into a process-global cache). On my test setup, this fixes inbox delivery to 10,000 local recipients from background queuedaemon running with a 32mb memory limit, completes the job within a minute from start. --- diff --git a/classes/Inbox.php b/classes/Inbox.php index 2533210b73..430419ba5e 100644 --- a/classes/Inbox.php +++ b/classes/Inbox.php @@ -115,9 +115,12 @@ class Inbox extends Memcached_DataObject */ static function insertNotice($user_id, $notice_id) { - $inbox = DB_DataObject::staticGet('inbox', 'user_id', $user_id); - - if (empty($inbox)) { + // Going straight to the DB rather than trusting our caching + // during an update. Note: not using DB_DataObject::staticGet, + // which is unsafe to use directly (in-process caching causes + // memory leaks, which accumulate in queue processes). + $inbox = new Inbox(); + if (!$inbox->get('user_id', $user_id)) { $inbox = Inbox::initialize($user_id); }