Thanks Nic,

I've tried taking the webclient out of the method and reuse it, but it
didn't help at all...

--
Matt

On Mon, Aug 6, 2012 at 4:19 AM, Nic Wise <[email protected]> wrote:

> I suspect that it's using an internal buffer somewhere. Maybe you need
> to dig into the source to work out whats being held onto.
>
>
> https://github.com/mono/mono/blob/master/mcs/class/System/System.Net/WebClient.cs
>
> But you could use a HttpWebRequest and have a lot more control over
> it, tho you then need to deal with streams and the like.
>
> also, what happens if you move the webclient out to object level, eg:
>
> void DoStuff()
> {
> WebClient client = new WebClient();
>
> becomes
>
> WebClient client;
> void DoStuff()
> {
> client = new WebClient();
>
> and
>
> void client_DownloadDataCompleted(object sender,
> DownloadDataCompletedEventArgs e)
> {
> var webClient = sender as WebClient;
> webClient.DownloadDataCompleted -= client_DownloadDataCompleted;
> webClient.DownloadProgressChanged -= client_DownloadProgressChanged;
> webClient.Dispose();
> webClient = null;
> //added
> client.Dispose();
> client = null;
>
> So, the GC can keep easier (maybe better, maybe not :) ) track of it?
>
>
>
> On Sun, Aug 5, 2012 at 7:34 PM, Matthieu Laban
> <[email protected]> wrote:
> > Hello Guys,
> >
> > My quest for leaks continues... I'm downloading files from our server,
> and
> > the size of the files can vary between 1 and 20 MB.
> > The issue is that after the file is downloaded, the app's dirty size
> goes up
> > ~20MB and never goes down even if I dispose the WebClient, remove all
> event
> > listeners and call GC.Collect().
> > If I run the download code a few times, it climbs 20 MB about 3x, then it
> > stops even if I call it again. Is there some kind of cache that is being
> > maintained or something? How can I make sure some of that memory is
> > reclaimed. We're tight on memory on the iPod Touch and we'd love to get
> some
> > of it back :)
> >
> > Here's the code that I'm running:
> >
> > void DoStuff()
> > {
> > WebClient client = new WebClient();
> > client.DownloadProgressChanged += client_DownloadProgressChanged;
> > client.DownloadDataCompleted += client_DownloadDataCompleted;
> > client.DownloadDataAsync(new
> > Uri("http://ipv4.download.thinkbroadband.com/20MB.zip";));
> > }
> >
> > void client_DownloadDataCompleted(object sender,
> > DownloadDataCompletedEventArgs e)
> > {
> > var webClient = sender as WebClient;
> > webClient.DownloadDataCompleted -= client_DownloadDataCompleted;
> > webClient.DownloadProgressChanged -= client_DownloadProgressChanged;
> > webClient.Dispose();
> > webClient = null;
> > GC.Collect();
> > GC.WaitForPendingFinalizers();
> > MessageBox.Show("Completed");
> > }
> >
> > --
> > Matt
> >
> >
> > _______________________________________________
> > MonoTouch mailing list
> > [email protected]
> > http://lists.ximian.com/mailman/listinfo/monotouch
> >
>
>
>
> --
> Nic Wise
> t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
> b. http://www.fastchicken.co.nz/
>
> mobileAgent (for FreeAgent): get your accounts in your pocket.
> http://goo.gl/IuBU
> Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
> Earnest: Self-employed? Track your business expenses and income.
> http://earnestapp.com
> Nearest Bus: find when the next bus is coming to your stop.
> http://goo.gl/Vcz1p
> London Bike App: Find the nearest Boris Bike, and get riding!
> http://goo.gl/Icp2
>
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to