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
- WebGL build dependencies are not refreshed until the Editor is restarted
- “Audio Random Container” allows adding unlimited number in “Audio Clips” numeric field, causing Editor to freeze
- In Deferred rendering path, mixed lights don't render when enabling "Use Rendering Layers" in the Decal renderer feature
- [Windows] Special characters in file names are sorted to the end of the alphabet in the Project window
- Information box icons are not contained within the information box bounds in Render Pipeline Converter window
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.