✅ Fix high memory usage #3126
Replies: 2 comments 9 replies
-
|
Hello @NicolasMahe
This is a very interesting and complicated type of investigations. I can only recommend you to seek for a way to exclude factors beyond the scope of your investigation:
as well as to use some tools, such as Node.js inspector, to make snapshots for figuring out the actual cause. Once you find it out — please let me know. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @RobinTail, I experimented with the Node.js inspector and found some interesting results regarding memory usage. Using a very simple
Most of the memory is attributed to the Looking closer at the
Similarly, the
I then investigated why TypeScript is being imported in such a simple app and found that it is pulled in by the following files:
To evaluate the impact, I removed these files and built a custom version of With this change, memory usage dropped to ~94 MB (–83 MB, roughly matching the difference I observe on Firebase Functions). I then took another heap snapshot:
Both the Conclusion It appears that most of the memory overhead comes from importing TypeScript, which is only required for the Simply moving the express-zod-api/express-zod-api/package.json Lines 51 to 61 in 4c0d8bd Let me know what you think — happy to help test or prototype a change. |
Beta Was this translation helpful? Give feedback.




Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm investigating an issue with unexpectedly high memory consumption in a project deployed on Firebase Functions.
As a baseline, the following minimal Express setup behaves as expected and uses little memory:
However, when I deploy the following version with a single express-zod-api endpoint the memory usage increases by roughly 70 MB:
Is this memory increase expected when using express-zod-api?
Do you have any recommendations to help reduce the library’s memory footprint in this context?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions