diff --git a/program/lib/Roundcube/rcube_cache.php b/program/lib/Roundcube/rcube_cache.php index fb1d5e184..a858c6ecd 100644 --- a/program/lib/Roundcube/rcube_cache.php +++ b/program/lib/Roundcube/rcube_cache.php @@ -308,6 +308,8 @@ class rcube_cache $data = $this->unserialize($sql_arr['data']); } + $this->db->reset(); + if ($nostore) { return $data; } diff --git a/program/lib/Roundcube/rcube_cache_shared.php b/program/lib/Roundcube/rcube_cache_shared.php index 290afe119..80d3c4236 100644 --- a/program/lib/Roundcube/rcube_cache_shared.php +++ b/program/lib/Roundcube/rcube_cache_shared.php @@ -302,6 +302,8 @@ class rcube_cache_shared $data = $this->unserialize($sql_arr['data']); } + $this->db->reset(); + if ($nostore) { return $data; } diff --git a/program/lib/Roundcube/rcube_db.php b/program/lib/Roundcube/rcube_db.php index ba3acf662..af6af05eb 100644 --- a/program/lib/Roundcube/rcube_db.php +++ b/program/lib/Roundcube/rcube_db.php @@ -773,6 +773,16 @@ class rcube_db return $this->last_result = $this->dbh->rollBack(); } + /** + * Release resources related to the last query result. + * When we know we don't need to access the last query result we can destroy it + * and release memory. Usefull especially if the query returned big chunk of data. + */ + public function reset() + { + $this->last_result = null; + } + /** * Formats input so it can be safely used in a query * diff --git a/program/lib/Roundcube/rcube_imap_cache.php b/program/lib/Roundcube/rcube_imap_cache.php index a402c1800..be9ef486f 100644 --- a/program/lib/Roundcube/rcube_imap_cache.php +++ b/program/lib/Roundcube/rcube_imap_cache.php @@ -353,6 +353,8 @@ class rcube_imap_cache } } + $this->db->reset(); + $msgs = array_flip($msgs); } diff --git a/program/lib/Roundcube/rcube_session_db.php b/program/lib/Roundcube/rcube_session_db.php index 6b996995b..342788246 100644 --- a/program/lib/Roundcube/rcube_session_db.php +++ b/program/lib/Roundcube/rcube_session_db.php @@ -106,6 +106,8 @@ class rcube_session_db extends rcube_session $this->vars = base64_decode($sql_arr['vars']); $this->key = $key; + $this->db->reset(); + return !empty($this->vars) ? (string) $this->vars : ''; }