Skip to content
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

https.request, https.get memory leak #37068

Open
noa-ru opened this issue Jan 25, 2021 · 7 comments
Open

https.request, https.get memory leak #37068

noa-ru opened this issue Jan 25, 2021 · 7 comments
Labels
https Issues or PRs related to the https subsystem. memory Issues and PRs related to the memory management or memory footprint.

Comments

@noa-ru
Copy link

noa-ru commented Jan 25, 2021

Hello all, it's a leak , right?
Simple code:

const https = require('https');

setInterval(function () {
    console.log(process.memoryUsage().rss);
    req();
    req();
    req();
}, 1000);

function req() {
    return https.get('https://www.google.com/', (res) => {
        console.log('statusCode:', res.statusCode);
    }).on('error', (e) => {
        console.error(e);
    });
}

rss, virt grow very quickly. i tried running GC manually too, but rss,virt does not decrease.
On production i use a 1 minute interval for 3 http-calls and in end of week i see, how oom-killer kill the node process.

node: v13.14.0
platform:
(prod): Linux 4.15.0-88-generic #88-Ubuntu SMP Tue Feb 11 20:11:34 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
(dev): Linux 4.15.0-130-generic #134-Ubuntu SMP Tue Jan 5 20:46:26 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

looks like this, only outgoing connections(and other node version) #31285
in profiler i too see like this: #31285 (comment)

@mscdex
Copy link
Contributor

mscdex commented Jan 26, 2021

Did you try at least calling res.resume()?

@mscdex
Copy link
Contributor

mscdex commented Jan 26, 2021

Also, have you tried this on any node LTS branches (e.g. 14.x)? Does the problem still exist on the master branch?

@noa-ru
Copy link
Author

noa-ru commented Jan 26, 2021

when i started using v13 it seems was LTS (maybe I'm wrong)

Did you try at least calling res.resume()?
Also, have you tried this on any node LTS branches (e.g. 14.x)? Does the problem still exist on the master branch?

no, I will try all soon and report the result, tnx

@mscdex
Copy link
Contributor

mscdex commented Jan 26, 2021

Odd-numbered major version branches (e.g. v11.x, v13.x, v15.x, etc.) never see an LTS release.

@noa-ru
Copy link
Author

noa-ru commented Jan 26, 2021

13.14.0 with resume - no effect (fast grow)
14.15.4 without resume - no effect (fast grow)
14.15.4 with resume looks normal

ok, i will start using 14.15 with resume. fast grow without resume - this is expected behaviour?

@Lxxyx Lxxyx added https Issues or PRs related to the https subsystem. memory Issues and PRs related to the memory management or memory footprint. labels Jan 27, 2021
@aarlaud
Copy link

aarlaud commented Sep 21, 2023

Hi, I'm facing a similar issue. Straight replacement from deprecated request, memory fills up really quickly and I can't figure out how to close/clean up this correctly. Is that still a known problem in node 18&20?

Thanks

@mscdex
Copy link
Contributor

mscdex commented Sep 21, 2023

@aarlaud Are you making sure to consume the response in one way or another?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
https Issues or PRs related to the https subsystem. memory Issues and PRs related to the memory management or memory footprint.
Projects
None yet
Development

No branches or pull requests

4 participants