Memory Leak, No Way!

clocy posted @ 2011年7月18日 04:28 in Development , 2093 阅读

Today I encountered the following debugger output when I ran my iPad application code:

2011-07-18 23:09:50.205 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b0fc60 of class __NSArrayM autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.207 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b10960 of class NSCFString autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.209 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b11bd0 of class NSCFString autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.211 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b11f60 of class NSPathStore2 autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.211 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b12170 of class NSPathStore2 autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.212 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b12380 of class __NSArrayI autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.212 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b124d0 of class NSPathStore2 autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.213 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b125e0 of class NSPathStore2 autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.214 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b12cf0 of class UIDeviceRGBColor autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.214 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b13010 of class __NSArrayM autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.215 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b0f960 of class __NSArrayM autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.216 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b12f80 of class NSCFString autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.216 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b13130 of class NSCFString autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.217 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b13030 of class NSPathStore2 autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.217 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b132d0 of class NSPathStore2 autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.218 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b131b0 of class __NSArrayI autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.219 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b131c0 of class NSPathStore2 autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.219 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b134f0 of class NSPathStore2 autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.220 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b133d0 of class NSCFString autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.221 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b13680 of class NSPathStore2 autoreleased with no pool in place - just leaking
2011-07-18 23:09:50.222 Whiteboard[55591:207] *** __NSAutoreleaseNoPool(): Object 0x4b13640 of class NSConcreteData autoreleased with no pool in place - just leaking

This is quite confusing, because for each background thread, I created its own NSAutoreleasePool, and of cource the main thread's NSAutoreleasePool is just out there in main.m, so what's the problem ? I use Instruments's leak detecting tool, it shows when the application bootstrap, it calls my singleton class ActionManager's load method which I used to load the data as a class helper method ([ActionManager load]). I suddenly realize that the problem is here !

Since each NSObject defines a load method as the cocoa documentation says: "Invoked whenever a class or category is added to the Objective-C runtime; implement this method to perform class-specific behavior upon loading". When the app runs, it call every needed class' load method. The ActionManager's load method is mistakenly override by me, that's why the debugger output these messages (Hmm, it even crashes my iPad sometimes). 

Avatar_small
Mike Ma 说:
Jul 22, 2011 07:41:38 PM

哥你英语太强大了,建议你去WordPress.com上做一个英语blog。。

Charles Brewer 说:
Feb 17, 2019 08:36:47 PM

A closed program and plan is divided for the effectiveness of the terms. The nature of the commodity and uk essay is marked for the satisfaction. THz nature is depicted for the hard times for the candidates in this ambit.

Michael Hussey 说:
Aug 29, 2019 01:14:25 AM

All things goes over my head because I didn't understand single thing due to I am very beginner in development site and also enrolled in CIPD courses and looking for place where I can buy cipd assignments I know all these codes and things that discuss above is hard to understand for beginners like me.

James 说:
Dec 06, 2019 06:31:33 PM

It seems like the main file is missing and not working properly. It can only be done through paid tool. Although, if you keep doing this it will fix the problem but it will occur again and crashes your iPad. Anyway, if you have any important college work to do you can go to online assignment help UK and assigned your task to any of the available writer. Easy!

eddie007 说:
Dec 24, 2019 08:30:24 PM

Now click here change of whatsapp status of your mobile. you will visit our site <a href="https://downloadstatus.xyz/category/new-year/">new year whatsapp status</a> and daily change many status.

eddie007 说:
Dec 24, 2019 08:30:59 PM

Now click here change of whatsapp status of your mobile. you will visit our site new year whatsapp status and daily change many status

melda20 说:
Feb 02, 2020 08:18:39 PM

Are you in need of Criminology Writing Services for your Custom Criminology Research Paper Writing Services? Seek our Online Criminology Essay Writing Services.

melda20 说:
Feb 02, 2020 08:19:15 PM

Acquiring Computer Science Writing Services is convenient? Seek Online Computer Science Writing Services from a reputable company for your Computer Science Writing Help Services online.

melda20 说:
Feb 02, 2020 08:19:46 PM

Is acquiring outstanding Biology Writing Services seems arduous for you? Seek our Custom Biology Writing Help from Best Biology Writing Service company..

melda20 说:
Feb 02, 2020 08:20:23 PM

Finding Religion and Theology Writing Services and Theology Writing Services to suit all your academic medical research requirements can be essay if you need Custom Religion and Theology Writing Services.

melda20 说:
Feb 02, 2020 08:20:50 PM

Psychology Writing Services are well known for the best Best Psychology Writing Services and award winning Psychology Writing Help Services.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter