Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6896397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:02:11+00:00 2026-05-27T07:02:11+00:00

Monotouch 5.0.2. Running the simple code below I get this in the output panel:

  • 0

Monotouch 5.0.2.

Running the simple code below I get this in the output panel:

objc[20283]: Object 0x9c08110 of class __NSCFString autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug
objc[20283]: Object 0x9c07840 of class __NSCFData autoreleased with no pool in place - just leaking - break on objc_autoreleaseNoPool() to debug

Which NSStrings are leaking here and why? It seems to be enough to just create a new Uri() and a new WebClient() objetc. The event handler doesn’t even have to be attached.

using System;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Net;
using System.IO;

namespace DownloadTest
{
    [Register ("AppDelegate")]
    public partial class AppDelegate : UIApplicationDelegate
    { 
        UIWindow window;

        public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            window = new UIWindow (UIScreen.MainScreen.Bounds);

            UIButton btn = UIButton.FromType (UIButtonType.RoundedRect);
            btn.Frame = new System.Drawing.RectangleF (40, 40, 100, 30);
            btn.TouchUpInside += delegate {
                // These two lines seem to caus the leak.
                Uri uri = new Uri ("http://silverlightinaction.com/video3.wmv");
                WebClient webClient = new WebClient ();
                // This line does not matter, the info about the leaking NSString alsp appears without an event being attached.
                webClient.OpenReadAsync (uri);                             
            };
            window.AddSubview (btn);

            window.MakeKeyAndVisible ();

            return true;
        }

        void HandleWebClientOpenReadCompleted (object sender, OpenReadCompletedEventArgs e)
        {
            using (var pool = new NSAutoreleasePool())
            {
                using (Stream stream = e.Result)
                using (FileStream fileStream = File.OpenWrite(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "download.bin")))
                {
                    stream.CopyTo (fileStream, 30000);
                    stream.Close ();
                    fileStream.Close ();
                }
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:02:12+00:00Added an answer on May 27, 2026 at 7:02 am

    This is a MonoTouch bug. WebClient uses Thread which does not automagically creates an NSAutoreleasePool around the code being executed (e.g. like you did in your delegate). That can cause some leaks – just like you’re seeing with the warning messages.

    Note that using (threads from) ThreadPool is already ensuring that an NSAutoreleasePool covers the thread’s execution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This Monotouch code below will not cause an exception, but it also won't show
On an iPad running iOS 4.3.5 I get this error: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.
In MonoTouch, how can we get the version of the bundle currently running? My
When running the below code, the app crashes (after ~30 seconds) with the below
I get a SIGABRT / ran out of trampolines error when running my MonoTouch
I have got an application developed with Monotouch 4.0.7. This app is running on
I accidentally bumped into an ad like this: http://monotouch.net/DownloadTrial?ref=so1 . Then I start to
This question is a duplicate of 1042830 , but MonoTouch-specific. Is there a way
This is probably a really simple question but I can't seem to find anything
iPHone: We use MonoTouch, but Obj-C answers are ok. My singleton domain object takes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.