(ROS) App crashes due to memory allocated

Hi everyone,

I’m new to Unity, and I’m currently using the Unity and ROS# to design and program my UI to communicate with the ROS machine.

I’m able to publish and subscribe to data such as sensor data and compressed image data in my UI. But when I hold my UI on the same page for around 10 to 15 mins, my app will crash automatically. At the same time, I can find my memory was being accumulated more than 10GB in the System Monitor on the Ubuntu system.

I tried searching online and find this Caching.ClearCache()in Unity API to clear the application’s cache. And added this in my void FixedUpdate()

May I know am I on the right way to try to solve this kind of problem? or which way should think about it.

Thank you so much.

(…) compressed image data (…)

  1. Are you creating new image every time the data changes?
  2. Are you releasing or reusing that image?

If the answer to the question #1 is “yes” and #2 is “no” - here is the reason for app crashing. Release or reuse.