From 5e54d5bc58dd815a84d12da1218c09e2c200b6eb Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 1 Mar 2024 10:08:25 +0100 Subject: Reduce API memory consumption (#6137) `echo json_encode(...)` is very memory demanding for large responses, so optimised. Contributes to https://github.com/FreshRSS/FreshRSS/issues/6136 https://github.com/FreshRSS/FreshRSS/pull/6013#discussion_r1506779881 --- p/api/greader.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'p/api') diff --git a/p/api/greader.php b/p/api/greader.php index 615f83567..d2fa810d0 100644 --- a/p/api/greader.php +++ b/p/api/greader.php @@ -715,8 +715,9 @@ final class GReaderAPI { $response['continuation'] = '' . $entry->id(); } } - - echo json_encode($response, JSON_OPTIONS), "\n"; + unset($entries, $entryDAO, $items); + gc_collect_cycles(); + echoJson($response, 2); // $optimisationDepth=2 as we are interested in being memory efficient for {"items":[...]} exit(); } @@ -805,8 +806,9 @@ final class GReaderAPI { 'updated' => time(), 'items' => $items, ); - - echo json_encode($response, JSON_OPTIONS), "\n"; + unset($entries, $entryDAO, $items); + gc_collect_cycles(); + echoJson($response, 2); // $optimisationDepth=2 as we are interested in being memory efficient for {"items":[...]} exit(); } -- cgit v1.2.3