Aleksandr Dubinsky
Aleksandr Dubinsky

Reputation: 23505

Silverlight on Mac - how to debug a Memory Leak?

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.

Upvotes: 3

Views: 355

Answers (3)

Aleksandr Dubinsky
Aleksandr Dubinsky

Reputation: 23505

It turned out that the HttpWebRequest.AllowWriteStreamBuffering = false bug (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.

Upvotes: 2

Mike Post
Mike Post

Reputation: 6460

I'd try running a profiler such as the SciTek .NET Memory Profiler against the Windows version and verify that you're properly disposing all of your objects and not actually leaking there. Hopefully this would properly translate to the Mac. (Most programmers are very bad at properly disposing their objects. And yes, it does matter.)

Upvotes: 0

Bryant
Bryant

Reputation: 8670

Have you tried setting up remote debugging on the mac? It might not track down the memory leak but at least you can step through the code to see what is going on.

Upvotes: 0

Related Questions