Skip to content

Fix: load_pc resize -> reserve#417

Merged
JanuszBedkowski merged 1 commit into
MapsHD:mainfrom
bloom256:fix/load-pc-resize-reserve
Apr 7, 2026
Merged

Fix: load_pc resize -> reserve#417
JanuszBedkowski merged 1 commit into
MapsHD:mainfrom
bloom256:fix/load-pc-resize-reserve

Conversation

@bloom256
Copy link
Copy Markdown
Collaborator

@bloom256 bloom256 commented Apr 7, 2026

Problem

PointCloud::load_pc calls resize(npoints) on points_local, intensities,
and timestamps, then appends real data with emplace_back. This creates
2*npoints elements: first half zero-initialized, second half real data.
std::vector::resize value-initializes new elements, which for numeric types
(double, unsigned short) means zero.

Why this bug is invisible

Phantom points have [0, 0, 0] local coordinates and timestamp == 0:

  • With downsampling: all phantom points fall into a single bucket at origin
    and are reduced to one point. No practical effect.
  • During export: points with timestamp == 0.0 are filtered out when
    skip_ts_0 is enabled (export_laz.h:418-421). Phantom points never reach
    the output file.

This bug affects only memory usage when point clouds are loaded without
downsampling.

Measurements

Dataset: 60.9M points, loaded without downsampling.

Before (resize) After (reserve)
Total points loaded 121,857,980 60,928,990
Peak during loading 11.3 GB 6.9 GB
Memory after loading 5.3 GB 3.4 GB

Fix

resize -> reserve on 3 lines in core/src/point_cloud.cpp.

@JanuszBedkowski JanuszBedkowski merged commit 6b6b500 into MapsHD:main Apr 7, 2026
7 checks passed
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

Successfully merging this pull request may close these issues.

2 participants