Closed tytremblay closed 2 years ago
Thanks for your feedback, rclnodejs replaced one of its dependencies, ref-napi
, which may cause this memory leak. Would you please help to test with v0.20.1 & nodejs12 to see if you can still reproduce it? Thanks!
I am unable to reproduce on v0.20.1 and node 12. I performed the test using the project attached to the original message.
After 750 messages, the RSS size was ~200MB. I repeated the same test with v0.21.0 and node 16 and, after 750 messages, the RSS size was ~950MB
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.
@tytremblay please try with the latest 0.21.1 to check if the issue is gone, thanks!
Thank you! The issue seems to be resolved. I updated to 0.21.1 and ran the above project. After 2000 messages, the RSS Size was ~200MB as expected.
@tytremblay good to know and thanks for your feedback!
Ty for the fix. Good job man.
Description 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.
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 andnpx 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