question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Memory Leak when subscribing to messages containing UInt8Array

See original GitHub issue

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.

  • 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:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
minggangwcommented, Mar 25, 2022

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.

0reactions
xhy279commented, Apr 25, 2022

Ty for the fix. Good job man.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Memory leak. ArrayBuffer finalizeCallback never called #917
I'm running into massive memory leaks when passing an array buffer from c++ to js. The callback given to the ArrayBuffer only gets...
Read more >
Memory leak when logging complex objects - Stack Overflow
The problem is that the objects that I pass stay in memory by the console. log method.
Read more >
4 Types of Memory Leaks in JavaScript and How to Get Rid Of ...
The main cause for leaks in garbage collected languages are unwanted references. To understand what unwanted references are, first we need to ...
Read more >
Debugging memory leaks in WebAssembly using Emscripten
Let's take a look at how you can debug those memory leaks and, ... Uint8Array backed by the WebAssembly (Wasm) memory buffer, with...
Read more >
Hunting memory leaks in a server side rendered React ...
Our memory leak was caused by reselect and with the bad usage of styled-components, both problems were found by using Chrome DevTools. Backstory....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found