-
Notifications
You must be signed in to change notification settings - Fork 843
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
Memory Leak #359
Comments
mark.It's seams I met the same problem. |
EJS just creates a function out of your template string, then runs it with your data as input parameters. It's highly unlikely that this is a memleak issue in EJS itself. (EJS is also a pretty widely used module, so any memleak issues would be visible to tons of people.) Since you're seeing this problem in the browser, it seems more likely that references to either the returned HTML, or to the created DOM node, are still hanging around, preventing that memory from getting GC'd. If you could provide a very minimal test to demonstrate this, I might be able to help, but I'm pretty sure this is an issue with your application, not with EJS. |
Hmmm, I think I might have met this problem too. |
What I'm seeing in the screenshot looks like a string variable for the source that the EJS Template object uses to compile into a runnable function. Depending on what's in your template text, this could be very large. |
Again, given how widely used EJS is, any memleak problem in EJS itself would be immediately visible to a huge group of people. If someone can provide a minimal test demonstrating a memleak in EJS, I'm happy to take a look, but I'm going to close this issue for now since it's mostly people talking vaguely about memleak issues in their apps, and nothing specific to EJS. We can certainly reopen if there's any evidence of a real memleak issue in EJS. |
Same problem here, with the @songzhuang @lxcid @secreter @jackycute @mde did you find any solution or workaround? |
I figure out that if you run your app inside a container you can limit to 256 MB the memory of the container to force the GC to clean up the unused references. In this way I fixed our situation. I'm also using EJS forcing with the option I tried to limit the memory management on node following this nodejs/node#7937 using Here is how it changed the memory allocation after the limitation on container level: |
Dear @mde i have encountered this issue too here is a copy of code that i have used to minimize the external variables, ignore the moment library its used for the ejs page i was loading from my project.
|
Can you tell me more about your solution i am facing the same issue |
@YounesTheGreat that app is run inside a Docker container on Kubernetes. |
@YounesTheGreat What we would need is a minimal example that uses only EJS, not multiple other libs including Express, and other unknown application code (e.g., public/landingpage). Your app uses EJS, and your app has a memleak. That does not mean that EJS has a memleak. |
Hi,
I have developed a system with node.js, express with ejs as the rendering engine. The application locks up after about 30 minutes of run time. Using the Chrome debugger, looks like there is a memory leak when ejs does the rendering. eg. If I click on a link 5 times, the html for the 5 is not garbage collected.
How would I handle this?
Thanks,
The text was updated successfully, but these errors were encountered: