-
-
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 #3552
Comments
Thanks for the report, we will look into this ASAP. Do you think this is the same as #3413 or different? |
@dougwilson I don't think so, but I did the same test with a basic node server and I seem to have the same issue
At this point we are really confused 😕 . Maybe you can help us find out if we are doing something wrong in the way we measure the memory consumption |
So I'm trying to reproduce the issue with the provided code and I'm not seeing the memory growth, unless I'm missing something? I'm using Express 4.16.1 and Node.js 7.6.0. Running that
It seems to just be sitting at the same heap memory as it started. Taking a heapdump before and after I'm not seeing any objects hanging around, either. What objects are you seeing being held in the heapdump? Am I missing a step somewhere? Here is what I did:
I then did it all again taking a heap dump between 3 and 4 and again between 4 and 5. |
There is always a possibility that the memory leak, if it's there, can be in Node.js's HTTP server implementation. Express doesn't really add much around it, and that is where all the complexity lies within a bare-bones Express app. |
Hi @dougwilson I tried in my computer with the same instructions, and here's my output:
|
FWIW I've tried this in my PC (but with node 9.3.0)
|
So are you guys seeing the memory leak? I put it on a loop since my last update and autocannon has run now 1231 times and the measurement says 719450 bytes. That is pretty much the same as my starting size of 7193660. I'm not sure how much I can really help if I cannot reproduce a memory leak, because to diagnose a memory leak, the first step is to use heapdumps to see what objects are actually leaking, and I keep taking the heapdumps and there is basically nothing in there between the autocannon runs, so I can't tell what would be leaking in order to know what Express needs to change. Any hints / tips on what objects you're seeing leaking would be super helpful. For example, can you take a heapdump on your end before the autocannons and after you have the leak so we do a comparison to see what the leaking objects are? |
@dougwilson I did some heap dumps, it seems that after the first run some of the memory is used for strings and another objects that seem to make sense, but after a second autocannon run there are some object that I don't know how to debug
There is a timer but I believe its because of the I just realized I did the test on an simple node HTTP server, but if you can help determine that the bug is actually on the Node HTTP implementation I'll make the issue in the node repo Here is the server code.
Thanks for all the help |
I too am getting memory leak related issues while using express, has this post made any progress since creation? |
I have not been able to reproduce the leak locally with the provided code, and neither has the Node.js core team. We need to be able to reproduce it to make progress, so any help getting it reproduced would be the next step. Another possibility is if someone is willing to allow myself or someone remote access to debug on a machine that is reproducing the issue, perhaps as a Skype call even. |
@dougwilson You can Remote connect to my local machine where I am developing if it will help? When is best for you, I am free for the next 2 hours. |
Hi @Starystars67 I am at work for the next 6 hours, so unable to do so right now. If you're available to do so over the weekend that would work, or if there is another time that is good, let me know and we can work something out 👍 |
Do you have discord? if so please add me on there and when you are available drop me a message and ill see what I can sort? Titch2000#6388 |
I've heard of it but don't have an account there. I'll sign up for one when I get off tonight 👍 |
@Starystars67 we will try to make a heavy load test next week to try to reproduce the same issues we are having in production |
Hi @dougwilson, Are you still interested in connecting to my local system to observe the issue? |
I'm still interested, I haven't forgotten. I just haven't gotten around to creating an account yet since it's a holiday weekend (in thr US). |
Okay buddy, do you have any idea on when you do think would be best for you? |
So tomorrow after work would be the next best time: Feb 20 around 7pm US eastern time. |
okay will make sure that I am free then. |
Sounds good. I'll get a Discord account setup prior to then so we can use it to screen share. |
Just as a heads up work went over today by half an hour, and just leaving my office now. Commute takes about an hour so will be about half an hour late. When I get home I'll create the Discord account and will contact you there 👍 |
Okay, just as a side note i am in the UK so please keep in mind it is already late but i am getting desperate in trying to solve the issue so i will stay up. See you soon |
Yes, very sorry, I couldn't control getting out on time. I sent you a friend request on Discord just now. |
i understand that buddy, just dont want to be messed around either |
Yea. So I'm not sure how to use Discord. I sent the friend request to your username above. Just message me on there 👍 |
@Starystars67 Any updates? |
Hi @igor-savin-ht, currently if you need something ASAP make sure you are not using the argument --inspect as this increases the memory leak size significantly, other than that @dougwilson is trying to see if he can locate the specific issue though it seems to be within Node v8 it's self. Node developers have been contacted though. |
@Starystars67 I downgraded to 4.15.2, but I don't know if it will work |
@donnanicolas Thanks! will get back to you when i can on the result. |
For those of you who are testing: You need to keep sustained traffic coming. For me, around 1 million / hour. And after about 30 minutes the leak becomes noticeable, and continues to grow. This is likely more related to the underlying http stack, as opposed to express itself, from what we can gather. Seems folks are having similar issues using Requests as well. |
@Hermities we believe the same as you, but we haven't been able to reproduce it locally |
when my self and @dougwilson were testing we reduced it all the way down to this:
and were still getting the leak |
Are the other people in this thread using Also, why go through the whole thing with adding manual garbage collection to the mix? Just make an actual reduced test case like I posted and use external tools to measure. If you are seeing different behavior when run with |
Not using ejs here. |
@wesleytodd Is that with the latest version or the version @donnanicolas mentioned? |
Latest express version, |
Perhaps the size of the return has an impact? All of mine are sending decent sized json object in the response. |
Can you post your application code? Or provide a workable application which exhibits the leak you are seeing? Because none of the examples posted here reproduce a leak for me. |
the version i posted causes a leak
and this was enough to cause a leak, a small one but a leak non the less |
@Starystars67 Can you remove the in process memory management stuff and try again? EDIT: I am not sure why we are here testing an |
@wesleytodd sure, how would you like me to monitor memory? is inspect what you was using or was you using something else? |
I'll work on a slimmed down test for the non ejs leak we are seeing. I've confirmed it across serveral servers and versions. The hard part is slimming it down and still productions the leak, tho. |
Hi @Hermities any progress on that? If you need me to come do a screen share where I can debug the leak through your code, I can do that too 👍 Unless there is a clear non-ejs-related leak shown in a few weeks, I'm going to close this issue without something concrete we can investigate and act on. I'm not dismissing your memory leaks, and want to fix them as much as you do, but if I don't have anything to reproduce and trace through, I have nothing to act on and no way to address them in the Express.js code base. Applications can get very complex and you have many, many modules in the mix, any one of which can cause a leak, so I'm not sure how you were able to narrow down that it is specifically Express.js that is leaking but are not able to provide a reproduce case we can take a look at...? Any guidance you can provide us to track the leak down and work on a fix is very appreciated 🙏 |
Hi @dougwilson Did we not strip it down past ejs to the point that it was using only NodeJS modules only? I thought the issue came down to NodeJS its self or am I wrong? Thanks :) |
Yes @Starystars67 in your case that is what we did. I'm sorry there are multiple people's memory leaks all in this same issue, and it seems as long as this issue is open, a new person comes along with a memory leak, spinning this issue further out of control and no longer able to focus on the previous memory leak diagnosis. |
@dougwilson Okay Sir, Thank you. did we get anywhere with contacting NodeJS Developers in getting my issue fixed? |
I was in contact with an inspector member by email (since the issue was only there in our reproduction when the inspector was attached) and they could reproduce it and I'm not sure if I heard back because I'm still working through the 500+ email backlog from the past week or so (which is why I'm circling back on this issue). You're always welcome to create an issue at https://github.com/nodejs/node/issues if you want to get a direct line to the Node.js team if you don't want to wait on a chain of a few people :) |
haha I see, in an effort to reduce your backlog I will create an issue yes. If you hear back before I should let me know and I will close the issue I will create now. EDIT* |
Closing per #3552 (comment) |
@nickydonna I am very curious what the end of the story was? Were you able to fix it? It's two years later but I am also seeing a similar thing in one production app.. |
We've been experiencing a memory leak in our node servers. Over the course of a day or so the memory in our servers started to fill until we got an alert and had to restart the app. We added new relic to check the node VM memory:
Upon debugging and testing we've come to the conclusion that the leak could be in express. We did some test on a clean express server, printing the heap before and after a lot of request and we see the memory increasing but never going back to the initial value.
We tested on various versions of Node and two versions of express (4.16.2 and 4.14.1) and we had the same results.
I'll add the last test setup so you can reproduce it.
Tested on OSX 10.12.6
Node 7.6.0
Express 4.16.1
Code
run with
node --expose-gc server.js
autocannon command
autocannon -a100000 -c5 http://localhost:9000/
Results:
This is just one of the many test we made, all with similar results
The text was updated successfully, but these errors were encountered: