I am using std::deque to receive imu ROS message and odometry ROS message and pop_back() when a lidar message is processed.
It is all working well. But after days of continuous running. The memory consumption goes up to to 90% on my 16 GB memory PC. I used heaptrack to pin down the problem and found std::deque::push_back() allocate 14 GB memory at peak and leak 14 GB memory at the same time. I am not using pointer, the definition of imu_queue is as below:
std::deque<sensor_msgs::Imu> imu_queue_;
I tested my program running for 1 hour. It allocated 1.5GB and leak zero. But the memory consumption do goes up as time went by.
Initially the memory of std::deque is almost none. I checked its size, since I pop_front() all imu message while processing lidar. deque's size is around 37 at most time.
I use shrink_to_fit() after a constant period. But the situation is still the same.