[MonoTouch] NSAutoreleaseNoPool error messages when using threads

Ed Anuff ed at anuff.com
Mon Oct 12 03:19:51 EDT 2009


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();
			
		}


More information about the MonoTouch mailing list