From 85dabbac6e83170f18b2f1e9e3d7c28c1bfb79b9 Mon Sep 17 00:00:00 2001 From: Symmetricity <184246+Symmetricity@users.noreply.github.com> Date: Mon, 11 May 2026 11:42:01 +0200 Subject: [PATCH] Reinitialize UsedObjects when enabling UsedObjects::clear frees its node tracking storage after the nodes phase. When reading multiple PBF inputs, the same OSMStore can enable usedNodes again for the next input. set() and test() expect the outer chunk table to exist, so recreate that table when enabling if it was previously cleared. Swap with an empty vector when clearing so the outer chunk table allocation is released rather than retained as capacity. --- src/osm_store.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/osm_store.cpp b/src/osm_store.cpp index 5bd6ef61..3055d3b1 100644 --- a/src/osm_store.cpp +++ b/src/osm_store.cpp @@ -32,6 +32,8 @@ bool UsedObjects::test(NodeID id) { void UsedObjects::enable() { status = Status::Enabled; + if (ids.empty()) + ids.resize(256 * 1024); } bool UsedObjects::enabled() const { @@ -51,7 +53,7 @@ void UsedObjects::set(NodeID id) { void UsedObjects::clear() { // This data is not needed after PbfProcessor's ReadPhase::Nodes has completed, // and it takes up to ~1.5GB of RAM. - ids.clear(); + std::vector>().swap(ids); } void OSMStore::open(std::string const &osm_store_filename)