After starting using next-i18next in our application, we detected a memory leak. After investigating, we saw that it was probably caused by something related to the library.
Using Chrome Devtools and --inspect flag of node in the example application provided by the repo, we found that a new i18n instance is allocated in memory after each request done to any page (e.g. /) and not freed when the request ends.
In the attached screenshot can be checked that there are 422 i18n instances, one for each request done in that particular test. This instances have a retained size of 10.5MB.
v0.54.0
We have used provided example application as-is, with its dependencies. To simulate the requests we have used artillery:
artillery quick -r 2 -d 10 http://localhost:3000
You should not see the memory leak.

This could very well be related to #184, and could be a regression.
We'll need:
@palaumarc Mind testing #451? And, if you have time, mind contributing to #452?
My ¢¢
I also noticed a memory leak in one Next.js app after upgrading a few deps in it about 10 days ago. Among them was bumping next-i18next from 0.42.0 to 0.52.1. The leak is rather slow and it feels like its speed depends on the the server load (more requests → faster memory consumption increase). After a few hours, server's RAM gets exhausted and the container gets killed.
I'm happy to try out a new release of next-i18next to confirm if the problem is still out there. For now, I had to rollback because I did not have time to investigate.
@palaumarc Mind testing #451? And, if you have time, mind contributing to #452?
I have tried it and it seems it works! (at least I can see only 2 instances of i18n in DevTools)
I am really busy this month but maybe I can try to do something on #452 next month.
When do you plan to release it? I will be on holidays until Monday but @gidina can do the follow up if required.
Thank you for your speed (both responding and fixing it).
FYI, snapshot of DevTools during the test:

When do you plan to release it?
Preferably when the PR is properly reviewed and tested against a real-world application.
I'm keen to help, but I don't know how to use next-i18next directly from the GitHub repo (doing so would require significant changes in CI sctipts, because the repo does not contain the dist). However, if you could publish 0.54.1-alpha.0 (without updating npm's latest version), I could give the fix a spin for a few hours in production tomorrow.
@kachkaev Actually, I am going to release v1 with #444. I'll start a v1 alpha to begin with and we can assume it's unstable until we get some use.
After upgrading next-i18next from 0.52.1 to 1.0.0 I no longer see any memory leaks – the app has been running for more than two days without crashing 🎉
Many thanks for a prompt fix @isaachinman!
Them same for us. Thanks @isaachinman !
Thanks @isaachinman! 🎉
Most helpful comment
I have tried it and it seems it works! (at least I can see only 2 instances of i18n in DevTools)
I am really busy this month but maybe I can try to do something on #452 next month.
When do you plan to release it? I will be on holidays until Monday but @gidina can do the follow up if required.
Thank you for your speed (both responding and fixing it).
FYI, snapshot of DevTools during the test:
