We were optimizing the memory usage during start up of our application and noticed there were lots of string allocations when creating the serializers.
I profiled the BasicUsage sample in Visual Studio and 7,211,352 total bytes were allocated in 1.9 seconds (slow because the profiler was attached). After the changes in this changeset these figures changed to 1,164,024 total bytes allocated and it finished in 1.1 seconds (again, this is slower than normal because the profiler was attached), so quicker and using a lot less memory during the creation of the serializers (less pressure on the GC, which was what we were investigating in our app in general so thought I'd pass the savings on to others ).
The cause is because the TextWriter.Null property returns an internal NullTextWriter class that only overloads the Write(string) method, meaning that anytime you call TextWriter.Null.Write("format", object) there's a call to string.Format which then gets thrown away. All I've done is generated a class that implements TextWriter and overrides all the methods it can and does nothing in them.
I've only modified the MsgPack.sln solution - there looks like there's an automated process for syncing the changes to the other solutions?
We were optimizing the memory usage during start up of our application and noticed there were lots of string allocations when creating the serializers.
I profiled the BasicUsage sample in Visual Studio and 7,211,352 total bytes were allocated in 1.9 seconds (slow because the profiler was attached). After the changes in this changeset these figures changed to 1,164,024 total bytes allocated and it finished in 1.1 seconds (again, this is slower than normal because the profiler was attached), so quicker and using a lot less memory during the creation of the serializers (less pressure on the GC, which was what we were investigating in our app in general so thought I'd pass the savings on to others ).
The cause is because the
TextWriter.Null
property returns an internal NullTextWriter class that only overloads theWrite(string)
method, meaning that anytime you callTextWriter.Null.Write("format", object)
there's a call tostring.Format
which then gets thrown away. All I've done is generated a class that implementsTextWriter
and overrides all the methods it can and does nothing in them.I've only modified the MsgPack.sln solution - there looks like there's an automated process for syncing the changes to the other solutions?