Memory Leaks in Jayrock.Json.Conversion.JsonConvert (Missing Dispose() calls)

66 views
Skip to first unread message

nsarris

unread,
May 27, 2012, 3:40:11 PM5/27/12
to jay...@googlegroups.com
I'm build a server app that collects data from a number of devices with JSON (making around 1000 async requests per 30 seconds). It seems that there's momery leakage. So far I have found out that not all of it comes from jayrock, but there are a lot of undisposed stream objects. I had to make a number of changes (mainly adding using blocks around streamreader objects). I am attaching the edited file.
JsonConvert.cs

Atif Aziz

unread,
May 29, 2012, 1:17:57 PM5/29/12
to jay...@googlegroups.com
I have reviewed your changes and most of them won't make much difference and even unnecessary. Perhaps the leak comes from assumptions that JsonConvert.Import is supposed to dispose your streams? The general policy used in Jayrock is that it disposes streams it owns or opens unless it passes the ownership to user code. Here would be the right way to use JsonConvert.Import, where user code opens and disposes the reader:
 
object obj;
using (var reader = File.OpenText("data.json"))
  obj = JsonConvert.Import(reader);
Process(obj);
 
- Atif

On Sun, May 27, 2012 at 9:40 PM, nsarris <nsa...@gmail.com> wrote:
I'm build a server app that collects data from a number of devices with JSON (making around 1000 async requests per 30 seconds). It seems that there's momery leakage. So far I have found out that not all of it comes from jayrock, but there are a lot of undisposed stream objects. I had to make a number of changes (mainly adding using blocks around streamreader objects). I am attaching the edited file.

--
You received this message because you are subscribed to the Google Groups "Jayrock" group.
To view this discussion on the web visit https://groups.google.com/d/msg/jayrock/-/_l20aQtmseoJ.
To post to this group, send email to jay...@googlegroups.com.
To unsubscribe from this group, send email to jayrock+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jayrock?hl=en.

Reply all
Reply to author
Forward
0 new messages