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
- Create Node Menu is not closing and “NullReferenceException: Object reference not set to an instance of an object” error is thrown when Shader Graph window is closed
- Assert error is thrown when the Editor language is set to one of the experimental ones in an HDRP project
- A BatchDrawCommand is using a pass from the shader “Universal Render Pipeline/Particles/Lit” that is not SRP Batcher compatible
- The Scene does not get rendered in the Player when MSAA is enabled and more than one Camera is used
- Crash on mono_object_get_class when generating Font Atlas of a specific font file
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.