Subscribe ( )

iPhone Programming Tutorials


 

Forum

You must be logged in to post Login Register

Search 

Memory Leaks

User Post

7:08 am
August 15, 2008


Nick

iCoder

posts 15

1

Just wondering if anyone has any tips on getting rid of memory leaks. I've run the 'fruit' example through Instruments and it seems to have a few, my application extends from this tutorial and seems to have similar leaks (and I'm guessing it's what's causing my crashes). 

Here's the screenshot:

I have no idea why the NSIndexPath would cause a leak, or how to fix it. Any help would be appreciated :)

Nick.

8:10 am
August 15, 2008


Admin

brandontreb

posts 88

2

Nick,

Good find.  I'm still racking my brain trying to find the bug in that tutorial.  It is very strange as I based that entire application off of Apple's SQLiteBooks example.  All I really did was remove the database component.  I will keep going over it until I find the solution.

I am sorry that you have experienced such trouble with it.  Download the SQLiteBooks example from Apple and compare your code.  Maybe you will have better luck spotting the bug.  Be sure to post your findings.

If debugging is the process of removing bugs, then programming must be the process of putting them in.
-Edsger Dijkstra

9:19 am
August 15, 2008


Admin

brandontreb

posts 88

3

I think I have solved it!

After reading the post left by daniel, I decided to investigate my choice for releasing the f object.

After some inspection, I realized that the “f” object wasn’t a new instance of Fruit, but a reference to an existing Fruit object.

Releasing this object, removes the Fruit at that cell from memory and causes the app to crash.

So to fix the crashing problem, remove the

[f release];

line from cellForRowAtIndexPath method inside of RootViewController.m.

Thank you to daniel for bringing this to my attention. I will update the tutorial later today.

If debugging is the process of removing bugs, then programming must be the process of putting them in.
-Edsger Dijkstra

7:05 pm
August 15, 2008


Nick

iCoder

posts 15

4

Thanks Brandon! That makes sense, as you don't actually alloc on the “f” object. 

I ran it through instruments and I still see one leak though :/ Have you tried it in that? 

The good news is my app doesn't crash any more, so i'm wondering if I should care about this one last leak or just be happy my application isn't crashing anymore :P

Thanks!

Nick.

12:05 am
August 19, 2008


OneEyed

Noob

posts 2

5

I've been working with the UITextView and I've come to the conclusion that it's design is faulty. 

You can safely do

[textView setText:@"Blah Blah"];

with no memory leaks what so ever, but when you do


NSString *blah = @”Blah Blah”;

[textView setText:blah];


This creates a memory leak.  They are both the same methods unless i'm not understanding something correctly?  I even tried releasing, autoreleasing, both blah and textView's text, but the methods that run in the background specifically because this is attached to a DOMHTMLElement it has something to do with that.  I first came upon this when I was logging some information and using setText on the textView.  I racked up an easy 1gb of memory =(


Search 

About the iCodeBlog forum

Most Users Ever Online:

44


Currently Online:

6 Guests

Forum Stats:

Groups: 2

Forums: 6

Topics: 419

Posts: 893

Membership:

There are 934 Members

There has been 1 Guest

There are 2 Admins

There is 1 Moderator

Top Posters:

bobcubsfan – 54

crazyiez – 30

Uhu – 17

AdeC – 17

Nick – 15

jitesh61 – 12

Administrators: Brandon (88 Posts), Collin (0 Posts)

Moderators: VertigoSol (26 Posts)



©   

  • Posted by on 6 Aug 2008 in Uncategorized
  •   |  
  •   |  
  •   |  
  • Comments Off

Comments are closed.