glim icon indicating copy to clipboard operation
glim copied to clipboard

Memory usage keeps increasing during large-scale mapping – eventually crashes at \~98%

Open mahmood-ul-hasan opened this issue 8 months ago • 3 comments

Thank you for your work on this project — it's been very helpful. I'm using ros2 glim_rosnode to build a large-scale map. After a certain point, memory usage steadily increases until CPU memory reaches approximately 98%, after which the node crashes. The following memory warnings repeatedly occur:

[glim_rosnode-1] [2025-05-30 14:57:35.294] [mem] [warning] CPU memory usage: 28979.05 / 31497.23 MB 92.01%
[glim_rosnode-1] [2025-05-30 14:57:40.294] [mem] [warning] CPU memory usage: 28938.97 / 31497.23 MB 91.88%
[glim_rosnode-1] [2025-05-30 14:57:50.295] [mem] [warning] CPU memory usage: 29336.95 / 31497.23 MB 93.14%

Eventually, it reaches >98% and the node crashes due to memory exhaustion.

Questions:

  1. Are there any parameters (e.g., cache size, voxel resolution, GPU memory use options) that can be adjusted to reduce memory usage or offload more to the GPU?
  2. Is there a recommended strategy for long-duration mapping with high memory efficiency?
  3. Is memory usage expected to grow indefinitely, or should it plateau during normal operation?

Any suggestions would be very helpful. Thanks in advance!

mahmood-ul-hasan avatar Jun 09 '25 04:06 mahmood-ul-hasan

  1. Please try tuning the following parameters:
    • Decrease "submap_target_num_points" in "config_sub_mapping_gpu.json" to 20000 ~ 30000 (decrease # points per submap)
    • Decrease "keyframe_voxelmap_levels" in "config_sub_mapping_gpu.json" to 1 (decrease # layers of voxelmaps per submap)
    • Increase "max_implicit_loop_overlap" in "config_global_mapping_gpu.json" to 0.3 ~ 0.4 (reduce # of factors in global optimization)
  2. If only the CPU-RAM matters, I recommend setting 16 ~ 32 GB swap memory to mitigate the problem https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04
  3. The memory usage grows indefinitely as the map area grows

koide3 avatar Jun 10 '25 02:06 koide3

@koide3 Thank you so much for your support and help.

mahmood-ul-hasan avatar Jun 11 '25 04:06 mahmood-ul-hasan

I implemented GPU memory offloading that enables swapping out submap data from the GPU memory and drastically reducing the memory consumption. You may want to try it: github.com/koide3/glim/pull/235

koide3 avatar Jun 26 '25 09:06 koide3