Closed tv42 closed 2 years ago
@tv42 there has been changes to the function (renamed escape_json_in_html
). Can you confirm that it still takes up large amount of memory with the latest version?
@tv42 can you please confirm whether this issue is still present? Otherwise we will close this issue shortly
This seems fixed.
In @sveltejs/kit@1.0.0-next.294, the memory use looks to be roughly equal to size of the JSON response (~1 MB JSON, ~1.1 MB allocated in render_json_payload_script
).
In older @sveltejs/kit@1.0.0-next.267, that was ~34 MB allocated in escape
.
npm run build && node --inspect node_modules/.bin/svelte-kit preview
Follow instructions at https://nodejs.org/en/docs/guides/debugging-getting-started/ to open inspector in browser. I'm assuming Chrome here for the instructions.
curl localhost:3000
Describe the bug
I was troubleshooting why my SvelteKit app SSR was consuming a lot of RAM. There's likely other reasons, but this jumped out of the profile:
escape_json_string_in_html
(which is just a wrapper forescape
, https://github.com/sveltejs/kit/blob/59badb515755a9294365e8084f9beefa10a90773/packages/kit/src/utils/escape.js#L53) allocates 23 MB for a 1MB input.Reproduction
From a Page's
load
function, make a fetch to a 1 MB JSON file, and return it as a prop.The SSR HTML will end with something like
containing said HTML, but creating that HTML apparently takes about 23x the size of the JSON in allocations.
Logs
No response
System Info
Severity
annoyance
Additional Information
No response