Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-06-2010, 10:27 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 20
lionfly is on a distinguished road
Default What "Memory leaks" should be ignored?

I have a project with about 2.2K Bytes memory leak, and can't get rid of it from analyzer, instruments, debugger etc.

I started a simple but unintelligent approach to check them out: I started a new blank project, to add each component one by one, and check the memory leak after each step.

Now I find the memory leak comes out even with only one blank Tab Bar Controller view in the executable, i.e. Malloc 144 Bytes, CoreGraphics, open_handle_to_dylib_path .

I then check the memory leak of Apple's example codes. For the LocateMe (LocateMe ), it has memory leak 144 Bytes in Simulator, 176 Bytes in iPhone Device. The screenshot of the Device memory leak is shown:

My question is: are there certain "memory leak" items unavoidable? What leaks we can ignore (e.g. if the leak does not increase more and more)?

Thanks for any suggestions.
lionfly is offline   Reply With Quote
Old 07-06-2010, 10:32 AM   #2 (permalink)
Registered Member
 
Join Date: Mar 2010
Location: Warwickshire, United Kingdom
Posts: 163
dcjones is on a distinguished road
Default

Hi,

I find it pays to run the analyzer, instruments, debugger etc from your device (iPhone) or whatever you have and not the simulator. You will get better results.

DCJ
__________________
Many thanks, keep safe and well.



Dereck
dcjones is offline   Reply With Quote
Old 07-06-2010, 11:37 AM   #3 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

So far I've seen 2 cases that I think can be safely ignored:

1. Any leaks that only happen on the simulator.
2. Any leaks that only happen the first time you use an SDK object. NSURLConnection is notorious for this. Make sure you run the same functionality several times to make sure it only leaks the first time.
JasonR is offline   Reply With Quote
Old 07-08-2010, 01:54 AM   #4 (permalink)
Registered Member
 
Join Date: Jun 2010
Posts: 16
noobdev is on a distinguished road
Default

Quote:
Originally Posted by JasonR View Post
So far I've seen 2 cases that I think can be safely ignored:

1. Any leaks that only happen on the simulator.
2. Any leaks that only happen the first time you use an SDK object. NSURLConnection is notorious for this. Make sure you run the same functionality several times to make sure it only leaks the first time.
Hi,

I just want to confirm, why would there be a difference in leaks depending on whether it's the phone or simulator?

That's a bit...scary...
noobdev is offline   Reply With Quote
Old 07-08-2010, 07:32 AM   #5 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

The process of detecting leaks is not an exact science. I can write some code that does not leak memory, but will appear to leak memory from instruments. All I have to do is have a hidden pointer to the "leaked" memory, and then, much later, release it through that pointer. An external observer has no way of knowing whether my program is capable of reclaiming that memory.

Use instruments and "build and analyze" as guides, but ultimately the question of whether you are leaking memory is dependent on whether you have allocated memory that you either cannot or will not ever release.

As was mentioned before, a one-time apparent leak is probably OK. But try very hard in testing to see if you can get such a leak to repeat indefinitely. If so, then you have something to worry about.
RLScott is offline   Reply With Quote
Reply

Bookmarks

Tags
coregraphics, malloc, memory leak

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 327
8 members and 319 guests
anothermine, Chickenrig, firecall, givensur, iNet, michaelhansen, PixelInteractive, stanny
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,892
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:29 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0