Closed aymeric-giraudet closed 2 months ago
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit 6b4141a2440533ca59607a7e68e390f27755508d:
Sandbox | Source |
---|---|
example-instantsearch-getting-started | Configuration |
example-react-instantsearch-getting-started | Configuration |
example-react-instantsearch-next-app-dir-example | Configuration |
example-react-instantsearch-next-routing-example | Configuration |
example-vue-instantsearch-getting-started | Configuration |
Hi @aymeric-giraudet It seems like next.js with its addInsertedHtml function causes a memory leak issue. If I comment out insertHTML call the memory leak is gone that of course breaks SSR. Have you considered not using ServerInsertedHTML but return Githubissues.
Summary
Got reports of memory leaks with the Next.js App Router solution. It seems partly related to
ServerInsertedHTML
or maybe just the fact that renders are streamed.Result
Prior to the change, on an index with stringified results weighing ~50kb, for 500 concurrent requests we had a peak of 1GB which reduced to 600mb when idle. By moving the initialisation of
createInsertHTML
so that it does not capture the scope of the whole component, it peaks at 600mb then reduces to 160mb when idle.There are definitely more ways this could be improved as I see stringified results are kept in memory way after, so does certain React nodes with results in them. Should try to see with the Next.js team perhaps.