code-iai / ROSIntegration

Unreal Engine Plugin to enable ROS Support
MIT License
411 stars 133 forks source link

Memory leaks in implementation of ConvertIncomingMessage #125

Closed BlueNoise closed 4 years ago

BlueNoise commented 4 years ago

Hi,

While adding more ROS messages that I will provide soon in a PR, I've realized that there is a memory leak that is happening in each ConvertIncomingMessage methods in the Converter classes. The problem is this line auto p = new ROSMessages::sensor_msgs::CompressedImage;

This means that every time a message is received, new memory is allocated, and never freed. You can witness this in the Task Manager, under Performance Tab in the Memory section. I've tried using smart pointers, but there is something I don't understand yet that is happening when the memory is freed that interacts with TSharedPtr &BaseMsg. The memory cannot be freed as its used outside the function, but it should only be allocated once. I have an idea on how to fix this, but it might not be ideal. I will try with my implementation of the new joint state message I am working on and see if I have a temporary way of fixing this problem.

BlueNoise commented 4 years ago

This was a false alarm. Memory management is fine!