2020-05-08

Memory Leak Issue

  • The direct cause of the memory leak is that a wild pointer was new’d but never delete’d.
  • After updating the current position, MapKit called prepareGuidanceData to find the guidance data closest to the current position.
  • prepareGuidanceData invoked NavInfoProviderImpl::getTrafficLights and NavInfoProviderImpl::getCarParks.
  • Taking NavInfoProviderImpl::getTrafficLights as an example, it news a data pointer in NaviEventOnPath at call time.
  • However, there is no corresponding delete.
  • It was also found that DestEvent has the same issue.

Solution: The core principle is to disallow wild pointers, so a refactoring of NaviEventProvider was decided upon.

  • First, add two fields traffic_light_events and car_park_events in NaviInfoProvider.
  • In NaviInfoGenerator, update these two fields after the route is updated.
  • Then, during each get call, filter based on the current vehicle position.
  • Therefore, PathReader::getAttributes needs to be refactored, because the previous implementation only considered the offset relative to the current vehicle, but now an offset interface relative to the Path is required.