-
Notifications
You must be signed in to change notification settings - Fork 6
Fix memory leak in automation demo visualization loop #847
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: kjy5 <82800265+kjy5@users.noreply.github.com>
Co-authored-by: kjy5 <82800265+kjy5@users.noreply.github.com>
Co-authored-by: kjy5 <82800265+kjy5@users.noreply.github.com>
|
@copilot The changes helped, but there is still a leak. Particularly when connected to manipulators. The memory grows more slowly now, but it still grows and needs garbage collection. I think this is due to the immutable state change system that the state system uses. Frequent updates to that are harsh. What suggestions are there to fix this? |
I've addressed the remaining leak caused by the immutable state system. The issue was that we were polling manipulator positions every 10ms (~100 Hz), which created:
Solution implemented (commit 8340aa5):
This reduces network requests and state allocations by 90%, from ~100/sec to ~10/sec. The visualization loop still runs at 100 Hz for smooth UI updates, but only fetches new positions and dispatches state updates at 10 Hz. The GC should now be able to keep up with the reduced allocation rate. |
2c963d1 to
16097ad
Compare
|
Superceded by #849 |
RAM grows continuously during automation demo due to allocations in the visualization update loop (runs at ~100Hz) and demo loop state retrievals.
Changes
Visualization loop (primary fix)
List<>instance instead of allocating new one every 10ms (~100/sec reduction)Where()with indexed for-loop to eliminate enumerator allocationsreturntocontinueto process all manipulatorsDemo loop
GetState<SceneState>calls from 5 to 1 per iteration (80% reduction)CheckDemoStillRunning()helper to deduplicate state checksState change handler
foreachwith for-loop inOnSceneStateChanged()Position request throttling
Example
Before:
After:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.