I’ve written a Silverlight app that works as an uploader for Amazon’s S3. It works fine on PC, but on Mac it has a huge memory leak.
The problem: I don’t know how to debug it. WinDbg, the top Google suggestion, obviously is out. I don’t think I can get a clue from inside of VS (when connected via remote debugging). And I haven’t checked, but I don’t imagine Mac OS debuggers will be useful.
The specific behavior is that as the file uploads, it stays in memory. Since files can be several GB in size, they can use up all memory and cause Silverlight to crash. I suppose it may be a bug in Silverlight, but maybe I can find a workaround if I knew the exact problem. On Windows there is also a confirmed bug https://connect.microsoft.com/VisualStudio/feedback/details/674960/writing-to-ms-internal-internalwebrequeststream-deadlocks-when-host-closes-request-stream#details that noone wants to fix.
That’s what I get for using a technology that’s been disowned by its maker, I guess.
It turned out that the
HttpWebRequest.AllowWriteStreamBuffering = falsebug (or my Windows workaround for it) was causing the horrible memory leak (and other deadlocks) on the Mac. So I was forced to enable buffering. Now everything works, at the cost flaky progress and upload speed reporting.Too bad I didn’t learn a method for inductively figuring this out. Had to discover it by more or less chance.