[OSRM-talk] Memory Leak?

Patrick Niklaus patrick.niklaus at student.kit.edu
Mon Feb 29 06:10:07 UTC 2016


Hey James,
which version of OSRM are you running on?

I would move the json_result object to the scope of the inner loop. It
is expected to empty when the function is called - might be there is a
vector filling up in there.

Cheers,
Patrick

On Sun, Feb 28, 2016 at 9:44 PM, James Grant <james at grantzone.net> wrote:
> Hi there.
>
> I've currently implemented some code based upon "simpleclient.cpp" which is
> very basic. However, when running through a loop to generate a number of
> routes, the memory decreases with each pass resulting in swap file
> eventually being brought into the equation. Once that happens, everything
> slows down!
>
> The basic bones of my code is shown below:
>
>                 // Set up the parameters required.
>                 RouteParameters route_parameters;
>                 route_parameters.zoom_level = 18;           // no
> generalization
>                 route_parameters.print_instructions = false; // turn by turn
> instructions
>                 route_parameters.alternate_route = false;    // get an
> alternate route, too
>                 route_parameters.geometry = false;           // retrieve
> geometry of route
>                 route_parameters.compression = false;        // polyline
> encoding
>                 route_parameters.check_sum = -1;            // see wiki
>                 route_parameters.service = "viaroute";      // that's
> routing
>                 route_parameters.output_format = "json";
>                 route_parameters.jsonp_parameter = ""; // set for jsonp
> wrapping
>
>                 // Start the outer loop.
>                 for(int oLoop = 0; oLoop < 10000; oLoop++)
>                 {
>                         // Start the inner loop.
>                         for(int iLoop = 0; iLoop < 10000; iLoop++)
>                         {
>                                 // Clear down the route parameters.
>                                 route_parameters.coordinates.clear();
>
>                                 // Start_coordinate
>
> route_parameters.coordinates.emplace_back(latlonPC[oLoop][0] *
> COORDINATE_PRECISION, latlonPC[oLoop][1] * COORDINATE_PRECISION);
>
>                                 // Target_coordinate
>
> route_parameters.coordinates.emplace_back(latlonPC[iLoop][0] *
> COORDINATE_PRECISION, latlonPC[iLoop][1] * COORDINATE_PRECISION);
>
>                                 // Run the required query.
>                                 routing_machine.RunQuery(route_parameters,
> json_result);
>                         }
>
>                 }
>
> Not a lot to it, therefore I'm wondering if the memory leak is in the
> RunQuery function and if so, how can I minimise the issue.
>
> Kind Regards
> James
>
> _______________________________________________
> OSRM-talk mailing list
> OSRM-talk at openstreetmap.org
> https://lists.openstreetmap.org/listinfo/osrm-talk
>



More information about the OSRM-talk mailing list