aboutsummaryrefslogtreecommitdiff
path: root/p/api
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-03-01 10:08:25 +0100
committerGravatar GitHub <noreply@github.com> 2024-03-01 10:08:25 +0100
commit5e54d5bc58dd815a84d12da1218c09e2c200b6eb (patch)
treede87559d5dfa6cf028752257290c882012e4f575 /p/api
parent96484d22a145fdef1d9002dc323f02e3b8ed2135 (diff)
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
Diffstat (limited to 'p/api')
-rw-r--r--p/api/greader.php10
1 files changed, 6 insertions, 4 deletions
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();
}