Search Issue Tracker
By Design
By Design in 6000.5.X
Votes
0
Found in
6000.0.68f1
6000.3.11f1
6000.4.0b9
6000.5.0a7
Issue ID
UUM-137151
Regression
No
Memory leaks and FPS slows down when Modifying Camera.rect or Camera.pixelRect
Reproduction steps:
1. Open the attached project "ReproProj"
2. Open the “/Assets/Scenes/SampleScene.unity” Scene
3. Enter the Play Mode
4. Open Memory Profiler (Window > Analysis > Memory Profiler)
5. Capture a Snapshot
6. Wait 2 minutes
7. Capture Snapshot again
8. Click Compare Snapshots
9. Select both Snapshots
10. Click All Of Memory tab
11. Compare Native memory
Expected result: Native, Untracked memory and FPS do not change
Actual result: Native and Untracked memory increases by 50-100 MB and FPS decreases
Reproducible with: 6000.0.68f1, 6000.3.11f1, 6000.4.0f1, 6000.5.0a7
Reproducible on:
Play Mode
Testing environment: Windows 10 Enterprise 21H2
Not reproducible on: No other environment tested
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Performance Markers Search window shows an empty entry in the list
- Enabling Deep Profiling in Performance Markers Search window breaks Inspector panel buttons when navigating through the marker items
- Dragging selector from selector row background shows preview but does not apply class in UI Builder
- An "InvalidOperationException" error is thrown when TryRemoveItem is used with rebuildTree set to false
- Build fails with IL2CPP error when building on Android platform in a specific project
Resolution Note:
Thank you for reporting a bug to Unity.
After reviewing the behavior, we've confirmed it aligns with the current design and intended use of the feature.
The behavior we observe is that enabling the camera rect randomizer leads to an increase in RAM usage. On the machine we tested this on, the Graphics Memory grows from ~500 MB to 1000 MB. After the intial growth, the RAM usage fluctuates in a stable range, and does not continue to grow any further. If the randomizer script is disabled, the RAM usage quickly drops back to the initial 500 MB usage.
Every time the camera rect is changed, the camera resolution is changed, too. This leads to camera-specific render targets being re-allocated in the new resolution. Temporary textures allocated via Render Graph will remain in the resource pool for 10 frames. This avoids having to re-allocate e.g. a texture that is used only every other frame. Instead, the texture from two frames ago is re-used.
Because the script triggers allocation of a different size render target every frame, it leads to having 10 frames worth of render targets allocated. This explains the increase in RAM usage.
Generally, changing the rect expensive, and should not be done every frame. The RAM overhead is expected.
Resolution Note (6000.5.X):
Thank you for reporting a bug to Unity.
After reviewing the behavior, we've confirmed it aligns with the current design and intended use of the feature.
The behavior we observe is that enabling the camera rect randomizer leads to an increase in RAM usage. On the machine we tested this on, the Graphics Memory grows from ~500 MB to 1000 MB. After the intial growth, the RAM usage fluctuates in a stable range, and does not continue to grow any further. If the randomizer script is disabled, the RAM usage quickly drops back to the initial 500 MB usage.
Every time the camera rect is changed, the camera resolution is changed, too. This leads to camera-specific render targets being re-allocated in the new resolution. Temporary textures allocated via Render Graph will remain in the resource pool for 10 frames. This avoids having to re-allocate e.g. a texture that is used only every other frame. Instead, the texture from two frames ago is re-used.
Because the script triggers allocation of a different size render target every frame, it leads to having 10 frames worth of render targets allocated. This explains the increase in RAM usage.
Generally, changing the rect expensive, and should not be done every frame. The RAM overhead is expected.