You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if you deserialize a model with lots of, say, boolean values in it: you get a lot of boxed booleans on the heap, from multiple sources, but mostly:
JsonTextReader.SetToken
new JValue(object, [JTokenType])
Suggestion:
create static readonly boxed objects for a range of likely primitive values
use the shared boxed copies in preference to vanilla boxing
avoid naïve and unnecessary new JValue(object) (side benefit: avoid some extra type testing)
This would significantly help (based on real testing with dotMemory etc) both the temporary gen-zero allocations of in-flight objects and the cost of retained JToken etc trees.
Happy to submit a PR if useful.
The text was updated successfully, but these errors were encountered:
mgravell
pushed a commit
to mgravell/Newtonsoft.Json
that referenced
this issue
Jan 14, 2022
Currently, if you deserialize a model with lots of, say, boolean values in it: you get a lot of boxed booleans on the heap, from multiple sources, but mostly:
JsonTextReader.SetToken
new JValue(object, [JTokenType])
Suggestion:
static readonly
boxed objects for a range of likely primitive valuesnew JValue(object)
(side benefit: avoid some extra type testing)This would significantly help (based on real testing with dotMemory etc) both the temporary gen-zero allocations of in-flight objects and the cost of retained
JToken
etc trees.Happy to submit a PR if useful.
The text was updated successfully, but these errors were encountered: