From aea38065901408c8b6d0bb0b619f21fd81fc9347 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 10 May 2020 21:34:12 +0200 Subject: Attempt to reduce max memory usage during actualize (#2955) * Attempt to reduce max memory usage during actualize #Fix https://github.com/FreshRSS/FreshRSS/issues/2952 * Use memory_get_peak_usage --- app/Models/Feed.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'app/Models/Feed.php') diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 34c036921..1b9bd6f9f 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -333,7 +333,12 @@ class FreshRSS_Feed extends Minz_Model { $guids = array(); $hasUniqueGuids = true; - foreach ($feed->get_items() as $item) { + // We want chronological order and SimplePie uses reverse order. + for ($i = $feed->get_item_quantity() - 1; $i >= 0; $i--) { + $item = $feed->get_item($i); + if ($item == null) { + continue; + } $title = html_only_entity_decode(strip_tags($item->get_title())); $authors = $item->get_authors(); $link = $item->get_permalink(); @@ -414,6 +419,7 @@ class FreshRSS_Feed extends Minz_Model { } $guid = $item->get_id(false, false); + unset($item); $hasUniqueGuids &= empty($guids['_' . $guid]); $guids['_' . $guid] = true; $author_names = ''; @@ -441,7 +447,6 @@ class FreshRSS_Feed extends Minz_Model { } $entries[] = $entry; - unset($item); } $hasBadGuids = $this->attributes('hasBadGuids'); -- cgit v1.2.3