From fcd8141e66f7bc2e35263fa48bff63cf5519a1fb Mon Sep 17 00:00:00 2001 From: Paul Mach Date: Thu, 1 Apr 2021 17:23:13 -0700 Subject: [PATCH] osmpbf: do not preallocate nodes --- osmpbf/decode_data.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/osmpbf/decode_data.go b/osmpbf/decode_data.go index 1f7f75e..a271dc2 100644 --- a/osmpbf/decode_data.go +++ b/osmpbf/decode_data.go @@ -309,17 +309,12 @@ func (dec *dataDecoder) extractDenseNodes() error { latOffset := dec.primitiveBlock.GetLatOffset() lonOffset := dec.primitiveBlock.GetLonOffset() - // we also assume all the iterators have the same length.... - - nodes := make([]osm.Node, dec.versions.Count(protoscan.WireTypeVarint)) - var id, lat, lon, timestamp, changeset int64 var uid, usid int32 - var index int for dec.versions.HasNext() { - n := &nodes[index] - n.Visible = true - index++ + // NOTE: do not try pre-allocating an array of nodes because saving + // just one will stop the GC from cleaning up the whole pre-allocated array. + n := &osm.Node{Visible: true} // ID v1, err := dec.ids.Sint64()