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
- ResolveUsePasses now extracts passes from all subshaders including fallbacks, in contrast to documented behaviour
- [UIBuilder] Changes aren't detected on types implementing IList
- [HDRP] Text is rendered with artefacts when using STP and resolution scale is set a float value
- [Settings Search] Search results not always matching search term correctly
- Crash on memcpy when opening a project that loads TSS files
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.