[MonoTouch] NSAutoreleaseNoPool error messages when using threads
Terry Westley
monotouch at sabonrai.com
Mon Oct 12 09:53:51 EDT 2009
You could be doing something that needs to be performed on the main UI
thread. If so, look into NSObject.InvokeOnMainThread and
NSObject.BeginInvokeOnMainThread.
--Terry
On Mon, Oct 12, 2009 at 3:19 AM, Ed Anuff <ed at anuff.com> wrote:
> I'm getting a lot of the following messages when I create a thread and
> create some objects inside of it that aren't used outside of the
> thread:
>
> 009-10-12 00:10:57.977 TouchClient[79105:4a03] ***
> _NSAutoreleaseNoPool(): Object 0x4966790 of class NSURL autoreleased
> with no pool in place - just leaking
> Stack: (0x62a6bf 0x58be62 0x5cb8a1 0x8ef58ce 0x8ef52da 0x8ef4d2e
> 0x4dd0490 0xca9d 0x1568d4 0x18fd8b 0x1c43c6 0x1eea08 0x96926f39
> 0x96926dbe)
> 2009-10-12 00:10:57.979 TouchClient[79105:4a03] ***
> _NSAutoreleaseNoPool(): Object 0x4abb80 of class NSCFString
> autoreleased with no pool in place - just leaking
> Stack: (0x62a6bf 0x58be62 0x5d8b0a 0x5e2f24 0x5e2ee8 0x8ef58ce
> 0x8ef5bdc 0x8ef4d3c 0x4dd0490 0xca9d 0x1568d4 0x18fd8b 0x1c43c6
> 0x1eea08 0x96926f39 0x96926dbe)
> 2009-10-12 00:10:57.980 TouchClient[79105:4a03] ***
> _NSAutoreleaseNoPool(): Object 0x4abb80 of class NSCFString
> autoreleased with no pool in place - just leaking
> Stack: (0x62a6bf 0x58be62 0x5d8b1c 0x5e2f24 0x5e2ee8 0x8ef58ce
> 0x8ef5bdc 0x8ef4d3c 0x4dd0490 0xca9d 0x1568d4 0x18fd8b 0x1c43c6
> 0x1eea08 0x96926f39 0x96926dbe)
> 2009-10-12 00:10:57.981 TouchClient[79105:4a03] ***
> _NSAutoreleaseNoPool(): Object 0x495dab0 of class NSCFString
> autoreleased with no pool in place - just leaking
> Stack: (0x62a6bf 0x58be62 0x6866e4 0x6126b9 0x5e2fda 0x5e2ee8
> 0x8ef58ce 0x8ef5bdc 0x8ef4d3c 0x4dd0490 0xca9d 0x1568d4 0x18fd8b
> 0x1c43c6 0x1eea08 0x96926f39 0x96926dbe)
>
> It's very simple code, basically retreiving some images. I tried
> null-ing out the allocated objects to see if that helped.
>
> public void CacheImage(string image_url, CacheImageCallback
> callback) {
> string file_path = GetPathForImageUrl(image_url);
>
> Thread thread = new Thread(new
> ThreadStart(delegate() {
> NSData data = null;
> NSUrl url = null;
> if (!File.Exists(file_path)) {
> url = NSUrl.FromString(image_url);
> data = NSData.FromUrl(url);
> if (data != null) {
> NSError err = null;
> if (data.Save(file_path,
> false, out err)) {
> Logger.Info("Image "
> + image_url + " saved to " + file_path);
> if (callback !=
> null) callback(image_url);
> }
> else {
> }
> }
> }
> else {
> if (callback != null)
> callback(image_url);
> }
> data = null;
> url = null;
> }));
> thread.IsBackground = true;
> thread.Start();
>
> }
> _______________________________________________
> MonoTouch mailing list
> MonoTouch at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monotouch
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monotouch/attachments/20091012/48d4c1a4/attachment-0001.html
More information about the MonoTouch
mailing list