8000 [Cache] Fix memory leak · symfony/cache@8d112fe · GitHub
[go: up one dir, main page]

Skip to content

Commit 8d112fe

Browse files
a1812nicolas-grekas
authored andcommitted
[Cache] Fix memory leak
1 parent 1c28afd commit 8d112fe

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Traits/AbstractTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ private function getId($key): string
281281
CacheItem::validateKey($key);
282282
$this->ids[$key] = $key;
283283

284+
if (\count($this->ids) > 1000) {
285+
array_splice($this->ids, 0, 500); // stop memory leak if there are many keys
286+
}
287+
284288
if (null === $this->maxIdLength) {
285289
return $this->namespace.$this->namespaceVersion.$key;
286290
}

0 commit comments

Comments
 (0)
0