-
-
Notifications
You must be signed in to change notification settings - Fork 17.4k
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 connected to EJS and PUG view engines #3751
Comments
Express doesn't really do anything but pass data between the two view engines. We can definitely take a look. Can you provide the following?
|
Also, just as an aside, can you try to test the following to verify if the memory leak is in ejs or express by testing this, which doesn't use Express? var http = require('http')
var ejs = require('ejs')
var fs = require('fs')
var template = fs.readFileSync('views/home/home.ejs', 'utf8') // or where ever your file is located
function app (req, res) {
res.setHeader('Content-Type', 'text/html')
res.end(ejs.render(template))
}
http.createServer(app).listen(3000) |
Dupe? #3552 I think we were pretty confident in that issue that there was a leak in ejs. |
var express = require('express');
var app = express();
app.set('view engine', 'pug');
app.get('/', function(req, res){
res.render('home/home');
});
app.listen(3000); //Pug view file doctype html
html
head
title RndSite
body
h1 Welcome to my memory test app
//Ejs view file <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<h1> Memory Test </h1>
</body>
</html>
|
Thanks @m-majetic ! Can you please validate #3751 (comment) ? |
Right, at least it doesn't seem to be in Express. Either Node.js HTTP server is causing it or (I suspect) the actual inspector itself is causing it as the leak only appears when the inspector is attached to the Node.js process; it doesn't seem to exist when there is no inspector. |
When testing in that issue, I did a test like @dougwilson suggests. Only when I added the I would go ahead and just remove the http stuff all together and try just rendering a file with both engines in a loop. Then check the memory usage for that. I believe, IIRC, you will find your leak in there. |
The thing is, I am getting the same leak using pug as well... @dougwilson |
Hi @m-majetic right, I get that it happens with both ejs and pug, but that still doesn't mean it is Express. It sounds like you tested with the basic app I provided that does not include Express at all. I think at this point it rules out Express as the contributing factor here. If you think otherwise on why specifically Express is causing the memory leak, please let us know and we can reopen to investigate further. |
I have tested two simple apps.
One using the ejs templating engine and the other using pug.
Both apps were tested with Siege. One route, and 5 - 20 concurrent users.
////////////////////////
EJS
////////////////////////
/////////////////////////////////
PUG
////////////////////////////////
In both tests I was using Express.js version 4.16.3, and latest versions of pug and ejs.
Edit -- wrong version of express stated...
The text was updated successfully, but these errors were encountered: