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
- ListView fails to display items when the source list is cleared and a single element is added
- UI Toolkit ':hover' state remains active when another panel is drawn over the hovered element and Touch input is used
- Unsupported Orient modes can be selected and throw errors when using Strip VFX
- "Tab" key exits the name text field in the VFX Graph tab when renaming the Property
- Shader warnings are thrown when deleting blocks in the Ribbon VFX Graph
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.