Skip to content

Conversation

tsctx
Copy link
Member

@tsctx tsctx commented Jul 6, 2024

> $ node memory.js // before
memoryUsage: 104Kib
> $ node memory.js // after
memoryUsage: 68Kib
const socket = new WebSocket("ws://localhost:5001")

socket.onopen = function () {
    const rss = process.memoryUsage.rss()
    socket.send("hi")
    socket.onmessage = function () {
        console.log(`memoryUsage: ${(process.memoryUsage.rss() - rss) / 1024}Kib`)
        socket.close()
    }
}

Refs: websockets/ws@ddfe4a8

@tsctx
Copy link
Member Author

tsctx commented Jul 6, 2024

It is effective because it can greatly reduce memory at the same performance.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@KhafraDev KhafraDev merged commit 64cd7a9 into nodejs:main Jul 6, 2024
@tsctx tsctx deleted the websocket/reduce-memory-usage branch July 6, 2024 20:44
@github-actions github-actions bot mentioned this pull request Dec 3, 2024
This was referenced Dec 16, 2024
@github-actions github-actions bot mentioned this pull request Mar 12, 2025
@github-actions github-actions bot mentioned this pull request May 12, 2025
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.

3 participants