Memory Leak when subscribing to messages containing UInt8Array
See original GitHub issueDescription It seems memory is not getting released for subscribers subscribing to messages containing a UInt8Array. If a sufficiently large array is published, the memory of the Node.js process can grow very quickly.
- Library Version: ^0.21.0
- ROS Version: foxy
- Platform / OS: Ubuntu 20.04.3 LTS (64-bit)
Steps To Reproduce
Attached is a small nodejs example of the issue I’m seeing. In the example, I have set up a publisher to publish a large image every 100ms. I’ve set up a subscriber to subscribe to that topic, and print process.memoryUsage().rss
each time it receives a message.
The example can be run by running npx ts-node server.ts
in a terminal window and npx ts-node client.ts
in another window.
When both are running, you can see that the memory footprint of the node process running the client grows whenever a message is received.
Expected Behavior Memory should not grow with each message
Actual Behavior Memory grows with each message rosleak.zip
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
Thanks for testing it! So I am pretty sure it is the change of
ref-napi
that leads to the memory leak, thanks for finding this critical issue! will fix it asap.Ty for the fix. Good job man.