Skip to content

Memory spike when emitting large objects without enforcing WS-only transports #2872

Closed
@nicholaswmin

Description

@nicholaswmin

Current behaviour

  • When there's no enforcement to use "Web Sockets" only as the transport
    protocol, the server logs a memory spike (> 500%) when emitting a big sample
    JSON.

  • When "Web Sockets" only are enforced, the server logs
    nominal memory consumption values whilst emitting the sample JSON.

Steps to reproduce

I've created a repo illustrating this issue, https://github.com/TheProfs/socket-mem-leak

Expected behaviour

  • When there's no enforcement to use "Web Sockets" only as the transport
    protocol, the server logs a nominal memory increase due to buffering, equal to the size of the emitted JSON (~10MB)

Setup

  • OS: Mac OSX, Linux
  • socket.io version: 1.7.3

Heap Metrics

Without enforcing WebSockets-only

Listening on 3000, using default transport (websocket & xhr)
Used heap size 34.91 MB
new connection
emitting 10 MB payload
Used heap size 659.31 MB
Used heap size 659.50 MB
Used heap size 659.56 MB
Used heap size 659.56 MB
new connection
emitting 10 MB payload
Used heap size 593.52 MB
Used heap size 593.65 MB
Used heap size 593.68 MB
Used heap size 593.68 MB

Enforcing WebSockets-only

Listening on 3000, using WebSocket-only transport
Used heap size 34.92 MB
new connection
emitting 10 MB payload
Used heap size 54.68 MB
Used heap size 54.68 MB
Used heap size 54.68 MB
new connection
emitting 10 MB payload
Used heap size 43.93 MB
Used heap size 43.97 MB
Used heap size 43.98 MB
Used heap size 43.98 MB

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions