Skip to content

Commit 86ffead

Browse files
committed
fix memory issue when dealing with large object lists
1 parent f2577c3 commit 86ffead

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

UPGRADE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Upgrade Notes
22

3+
## 3.0.3
4+
- [IMPROVEMENT] fix memory issue when dealing with large object lists (#41)
35
## 3.0.2
46
- [LICENSE] Dual-License with GPL and Dachcom Commercial License (DCL) added
57
## 3.0.1

src/Service/Builder/ObjectListBuilder.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ public function buildByList(array $options): \Generator
3232
{
3333
$list = $this->getList($options);
3434

35-
foreach ($list->loadIdList() as $id) {
36-
if ($object = DataObject::getById($id)) {
35+
$idList = $list->loadIdList();
36+
for ($i = 0; $i < count($idList); $i++) {
37+
if ($object = DataObject::getById($idList[$i])) {
3738
yield $object;
3839
}
40+
if ($i % 400 === 0) {
41+
\Pimcore::collectGarbage();
42+
}
3943
}
4044
}
4145

0 commit comments

Comments
 (0)