[OSRM-talk] Memory Leak?

James Grant james at grantzone.net
Sun Feb 28 20:44:07 UTC 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/osrm-talk/attachments/20160228/7ba481fa/attachment.html>


More information about the OSRM-talk mailing list