summaryrefslogtreecommitdiff
path: root/classes/Inbox.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-06-01 13:53:44 -0700
committerBrion Vibber <brion@pobox.com>2010-06-01 13:53:44 -0700
commit17ab15a3d02c335f2d9d333ac3773c037e796cf5 (patch)
tree1b3f476699cee644c0fe518049f7844c6f3a22a5 /classes/Inbox.php
parent634752f0d262b4fb02456889250378fca084cd2e (diff)
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.
Diffstat (limited to 'classes/Inbox.php')
-rw-r--r--classes/Inbox.php9
1 files changed, 6 insertions, 3 deletions
diff --git a/classes/Inbox.php b/classes/Inbox.php
index 2533210b7..430419ba5 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);
}