-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
src: plug memory leaks #2352
src: plug memory leaks #2352
Conversation
Argh, @trevnorris ! |
@@ -223,7 +223,8 @@ void StreamWrap::OnReadImpl(ssize_t nread, | |||
CHECK_EQ(pending, UV_UNKNOWN_HANDLE); | |||
} | |||
|
|||
Local<Object> obj = Buffer::New(env, base, nread).ToLocalChecked(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, this one takes the ownership of base
. You should not really fix it.
@bnoordhuis are you sure that they are leaking? I thought ArrayBuffer just takes ownership of them now? |
|
Oh gosh, I was looking at it yesterday too. Looks like I was looking at wrong overloaded function then. Shouldn't it be |
I thought |
There's no leak with |
Switched to |
Gave it a test run. It's an improvement, but still not anywhere near 2.5.0's almost constant usage in my FormData testcase. Will test further. |
Fixed CI: https://jenkins-iojs.nodesource.com/job/node-test-pull-request/76/ (The default parameters were failing because they were still pointing to the io.js repo) |
The implementation of It was an oversight on my part to leave the internal implementation of |
c69de44
to
40cf5e9
Compare
PTAL, I added Buffer::Copy() and renamed Buffer::Use() to Buffer::New(). CI: https://jenkins-iojs.nodesource.com/job/node-test-pull-request/83/ |
This looks to fix the leak in my simple test (#2308 (comment)) completely, good job. I still see leakage in the FormData test (https://gist.github.com/silverwind/54b3829142f93d1127bc), but I'd say it's a important first step to land this now. |
Nice job. LGTM. |
LGTM! |
In a few places dynamic memory was passed to the Buffer::New() overload that makes a copy of the input, not the one that takes ownership. This commit is a band-aid to fix the memory leaks. Longer term, we should look into using C++11 move semantics more effectively. Fixes: nodejs#2308 PR-URL: nodejs#2352 Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
The circular dependency problem that put them there in the first place is no longer an issue. Move them out of the public node_buffer.h header and into the private node_internals.h header. Fixes: nodejs#2308 PR-URL: nodejs#2352 Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
Rename the three argument overload of Buffer::New() to Buffer::Copy() and update the code base accordingly. The reason for renaming is to make it impossible to miss a call site. This coincidentally plugs a small memory leak in crypto.getAuthTag(). Fixes: nodejs#2308 PR-URL: nodejs#2352 Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
Fixes: nodejs#2308 PR-URL: nodejs#2352 Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Trevor Norris <[email protected]>
40cf5e9
to
8841947
Compare
In a few places dynamic memory was passed to the Buffer::New() overload
that makes a copy of the input, not the one that takes ownership.
This commit is a band-aid to fix the memory leaks. Longer term, we
should look into using C++11 move semantics more effectively.
R=@indutny, refs #2308.
I think there is another memory leak in TLSWrap::OnReadSelf() but parallel/test-https-drain starts failing erratically when I fix it... le sigh.
CI: https://jenkins-iojs.nodesource.com/job/node-test-pull-request/72/