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

Release memory used by PerMessageDeflate extension #608

Merged
merged 1 commit into from
Nov 26, 2015

Conversation

darrachequesne
Copy link
Contributor

Hi! It seemed the memory allocated by perMessageDeflate is not properly freed, thus causing memory leaks when this feature is enabled (as reported here #497)

As documented here and implemented here, calling .close() on DeflateRaw and InflateRaw objects should (at least partially) fix these leaks.

Related: socketio/socket.io#2251

(please tell me this is it)

@darrachequesne
Copy link
Contributor Author

(just to be sure ☀️) ping @3rd-Eden @nkzawa

@nkzawa
Copy link
Contributor

nkzawa commented Nov 2, 2015

👍 awesome

But I'm not sure if this is the root cause, since zlib objects should be released with socket instances when no reference exists.
Anyway explicit cleaning up would be nice.

@darrachequesne
Copy link
Contributor Author

@nkzawa hi! that's what I thought too, but running the following gist seems to show a different behaviour

  • with perMessageDeflate: false, RSS tends to stabilize around 70 Mo
  • with perMessageDeflate: true (without this commit), RSS tends to stabilize around 180 Mo
  • with perMessageDeflate: true (with this commit), RSS tends to stabilize around 100 Mo

Meanwhile, the HeapSize goes up and down (which is normal, as GC runs).

Are you able to reproduce my results? Or is there a problem with my test?

I mean, the extra memory is normal, as it comes as a cost for compression (as said here). But as said here (that's a lot of links 😄), memory has to be deallocated by calling deflateEnd() (or inflateEnd()), which is what .close() does here.

But it may not be the root cause (and that's where I need your help).

Note: node -v returns v0.12.7

@nkzawa
Copy link
Contributor

nkzawa commented Nov 13, 2015

Hi, sorry for the delay. I could reproduce similar results with your scripts, but maybe this means it's not leak? Though I have no idea about the difference of RSS.

@darrachequesne
Copy link
Contributor Author

You're right, the term 'leak' was probably wrongly used here, please excuse me.

I found this nodejs/node-v0.x-archive#4172. Could this be related and explain the difference in RSS? (as we are now explicitly calling .close())

Source: https://github.com/nodejs/node/blob/master/src/node_zlib.cc#L97

@rauchg
Copy link
Contributor

rauchg commented Nov 23, 2015

@3rd-Eden can you merge please?

@3rd-Eden
Copy link
Member

PR will be adressed this week. Sorry for the hold up.

@darrachequesne
Copy link
Contributor Author

Great, thanks!

3rd-Eden added a commit that referenced this pull request Nov 26, 2015
Release memory used by PerMessageDeflate extension
@3rd-Eden 3rd-Eden merged commit 6e4ccca into websockets:master Nov 26, 2015
@yuyi
Copy link

yuyi commented Sep 4, 2016

Maybe this issue is still at #804 .

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 this pull request may close these issues.

None yet

5 participants