Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Method RouterDb.AddContracted took 3h and throws OutOfMemory exception #316

Open
Georgy-Losenkov opened this issue Jun 25, 2020 · 1 comment

Comments

@Georgy-Losenkov
Copy link

I am using nuget packages version 1.5.0.
Below is code that I used. Similar code on same machine using Osm.Routing.dll (v0.4.5.143) finished in 5 minute:

        static void PrepareDatabase()
        {
            var routerDb = new RouterDb();
            Console.WriteLine(DateTime.Now);
            Console.WriteLine("Loading from pbf");
            // file downloaded from "https://download.geofabrik.de/russia-latest.osm.pbf"
            using (var stream = new FileStream(@"C:\Maps\russia-latest.osm.pbf", FileMode.Open, FileAccess.Read, FileShare.Read, 1048576))
            {
                routerDb.LoadOsmData(stream, false, Vehicle.Car);
            }

            Console.WriteLine(DateTime.Now);
            Console.WriteLine("Adding contracted Car");
            routerDb.AddContracted(Vehicle.Car.Shortest()); // <-- OutOfMemory here (9GB memory)

            Console.WriteLine(DateTime.Now);
            Console.WriteLine("Saving database to memory");
            using (var stream = new System.IO.MemoryStream())
            {
                routerDb.Serialize(stream, true);

                Console.WriteLine(DateTime.Now);
                Console.WriteLine("Saving database to disk");
                using (var fileStream = new FileStream(@"C:\Maps\russia-latest.osm.pbf.router", FileMode.Create, FileAccess.ReadWrite, FileShare.Read))
                {
                    stream.Position = 0;
                    stream.CopyTo(fileStream);
                }
            }

            Console.WriteLine(DateTime.Now);
            Console.WriteLine("Finished");
        }
@juliusfriedman
Copy link

From what I recall the nuget packages were not able to work in 64 bit despite being built for anycpu.

You must build them manually for x64.

If your going to do that I suggest getting the latest https://github.com/itinero/reminiscence and to also see #302

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants