From eb1d4cae3924cd73e4677e3ade542f63e7950254 Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Thu, 25 Jan 2024 13:25:49 -0800 Subject: [PATCH] BVHAggregate: add shrink_to_fit() call after resize(0) So it turns out this is necessary to actually free the memory... Via Keith Jeffery. --- src/pbrt/cpu/aggregates.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pbrt/cpu/aggregates.cpp b/src/pbrt/cpu/aggregates.cpp index 53eb8c42b..f86aad504 100644 --- a/src/pbrt/cpu/aggregates.cpp +++ b/src/pbrt/cpu/aggregates.cpp @@ -177,6 +177,7 @@ BVHAggregate::BVHAggregate(std::vector prims, int maxPrimsInNode, // Convert BVH into compact representation in _nodes_ array bvhPrimitives.resize(0); + bvhPrimitives.shrink_to_fit(); LOG_VERBOSE("BVH created with %d nodes for %d primitives (%.2f MB)", totalNodes.load(), (int)primitives.size(), float(totalNodes.load() * sizeof(LinearBVHNode)) / (1024.f * 1024.f));