New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ssrLoadModule uses 4+ GB of memory when loading 50+ MB files and causes crash due to OOM #11745
Comments
It seems removing this line reduces the memory usage significantly.
I guess this is related to Rich-Harris/magic-string#195, Rich-Harris/magic-string#217. |
That's the sourcemap generation, right? Would it be possible to disable sourcemap generation for JSON and |
Looking at the code I get the impression that just disabling |
This seems to be much improved in Vite 4.5.0 now:
Closing as it doesn't crash anymore. |
Describe the bug
When using
ssrLoadModule
to load files, the memory required to load files appears to be very large. In my testing about 100x larger than the size of the file itself.This is problematic in particular when attempting to load large JSON files or text files (using
?raw
) for use on the server. On my computer the memory usage is so large that loading a 50 MB file causes node to crash due to running out of memory. On my older computer, which has 8 GB of RAM, it is even worse, with 30 MB and sometimes even 20 MB files causing a crash.(I originally found this issue when trying to import a large JSON file in a SvelteKit endpoint and filed it as sveltejs/kit#8592)
Reproduction
https://github.com/FeldrinH/vite-oom-repro
Steps to reproduce
Run
npm install
followed bynode --expose-gc test.js
System Info
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: