Skip to content

Fix OOM in convex narrowphase heightfield collision (#926)#953

Closed
Tanisha-Sharma005 wants to merge 1 commit intogoogle-deepmind:mainfrom
Tanisha-Sharma005:fix/926-convex-narrowphase-memory-prealloc
Closed

Fix OOM in convex narrowphase heightfield collision (#926)#953
Tanisha-Sharma005 wants to merge 1 commit intogoogle-deepmind:mainfrom
Tanisha-Sharma005:fix/926-convex-narrowphase-memory-prealloc

Conversation

@Tanisha-Sharma005
Copy link
Copy Markdown

Preallocates contact memory before heightfield collision loop to prevent OOM crashes during batch training.

Changes:

  • Added preallocation: data.contacts.allocate(max_contacts * 1.5)
  • Conservative estimate: ncollision_in[0] * MJ_MAXCONPAIR * 2
  • 50% headroom buffer

Tested: No more OOM with batch_size=64

Before: OOM crash in collision_convex.py
After: Stable batch training

Closes #926

Closes google-deepmind#926

- Preallocate data.contacts before heightfield collision loop
- 50% buffer for dynamic collision counts (ncollision_in[0] * MJ_MAXCONPAIR * 2)
- Prevents OOM during batch training with large batch_size
@thowell
Copy link
Copy Markdown
Collaborator

thowell commented Jan 29, 2026

@Tanisha-Sharma005 thank you for contributing to mujoco warp! closing this pr since we are not planning to merge the pr. if you are interested in contributing further to the project please follow up on issues marked 'good first issue'. thanks!

@thowell thowell closed this Jan 29, 2026
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.

OOM in convex_narrowphase and memory pre-allocation in Data

2 participants