Search Issue Tracker
Won't Fix
Votes
1
Found in
2017.4.0f1
Issue ID
1022586
Regression
No
Using JsonUtility.FromJsonOverwrite to deserialize objects with array/list fields, unexpected/inconsistent GC alloc happens
To reproduce:
1. Open attached project
2. Open "BugRepo" scene
3. Enter play mode
4. Open Profiler and enable deep profile
5. Notice allocations under JsonTest.Update()
Using JsonUtility.FromJsonOverwrite to deserialize objects with array/list fields, unexpected/inconsistent GC alloc happens.
Cases:
1) deserializing into array with same number of elements
2) deserializing into array with different number of elements
3) deserializing into list with same number of elements
4) deserializing into list with different number of elements
Actual results:
1) no alloc
2) new array allocated, then each element in new array allocated
3) GC.Alloc call (list reference on my object doesn't change)
4) list ref instance is the same, but more allocations than case (2)
Expected results:
1) no alloc (ok)
2) array reallocated, added elements allocated if needed (old elements replaced)
3) no alloc
4) no alloc if list Capacity is enough to contain new items
Reproducible: 2018.3.0a1, 2018.2.0b1, 2018.1.0f2, 2017.4.2f1
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
- “Remove Unused Overrides” available on not loaded Scene and throws “ArgumentException: The scene is not loaded” warning
- Adaptive Probe Volume occlusion edge is calculated incorrectly when viewing probes near geometry edges
- Sampling a texture using an HLSL file throws shader errors and the code does not compile
- "Graphics.CopyTexture called with null source texture" error when Base Camera of an Overlay Camera is removed with DX11 Graphics API and Compatibility Mode enabled
- WebGL sends wrong value with large numbers when SendMessage function is used
Resolution Note:
This particular case has been investigated thoroughly and we have decided, in the interests of protecting the stability and features of Unity for users that rely upon the affected versions, to not address this fix for the time being. We understand that this will cause problems for some users, and so may address in a future version.