I'm using Newtonsoft.Json to parse Jsons of about 100MB in size. I'm deserializing them into dynamic objects to work with them later. I was expecting the app to not use much more than the 100MB of ram, however this it not the case at all. I made a debug application to test the memory usage and to my surprise, it is at 435MB after deserializing.
I'm using a memory effcient code with disposing and streams:
dynamic json; using (StreamReader sr = new StreamReader("C://Users/Brigan/JSON.json")) using (JsonReader reader = new JsonTextReader(sr)) { JsonSerializer serializer = new JsonSerializer(); json = serializer.Deserialize<dynamic>(reader); }
This is all the application does. The code was taken and changed for reading a file from the official suggestions at https://www.newtonsoft.com/json/help/html/Performance.htm#MemoryUsage.
Looking at the memory profile: Object type : Amount : Size in bytes : Total size in bytes
2.1m questions
2.1m answers
60 comments
56.9k users