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

request.js does not explicitly set buffer to null which is referenced by a closure #1723

Closed
smithbk opened this issue Aug 10, 2015 · 0 comments · Fixed by #2168
Closed

request.js does not explicitly set buffer to null which is referenced by a closure #1723

smithbk opened this issue Aug 10, 2015 · 0 comments · Fixed by #2168

Comments

@smithbk
Copy link

smithbk commented Aug 10, 2015

On line 1011 of request.js, he variable 'buffer' references an array which can become quite large depending on the size of the response body. Since the 'buffer' variable is referenced in a closure and never explicitly set to null, the buffer remains referenced for the life of the response object and can not be garbage collected. It would be much safer to prevent memory leaks, and minimally more efficient to set 'buffer = null' as soon as it is no longer required by this code so that it can be garbage collected.

0x1mason added a commit to 0x1mason/request that referenced this issue Apr 13, 2016
This fixes the issue mentioned in request#1723. The lifetime of the `buffer` variable defined in `readResponseBody` is linked to the `Request` object, rather than the enclosing function. This can lead to leaky behavior if references to the request persist in memory.

This PR simply destroys the buffer after it is no longer needed.
simov pushed a commit that referenced this issue Apr 14, 2016
* Explicitly destroy response buffer

This fixes the issue mentioned in #1723. The lifetime of the `buffer` variable defined in `readResponseBody` is linked to the `Request` object, rather than the enclosing function. This can lead to leaky behavior if references to the request persist in memory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant