0

For anyone who's trying to read this question, there have been extensive discussions between me and Jonas and the question changed over the course of the discussion several times so there would be no use in restating everything we went through here. If you have problems reading a crash log please refer to this question on stackoverflow! Thank you for your understanding.

Jonas: Here's the code snippet I was referring to in my last comment:

if ([performance.favorites integerValue] == 1) {
        UIImage *starImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"fav-star" ofType:@"png"]];

        cell.favoritesImage.image = starImage;
    }
    else
    {
        cell.favoritesImage.image = nil;
    }

So if the else block is executed, would that make the [favoritesImage release] call crash if a TableViewCell that is not showing the favorites Image is being deallocated?

So I could simply instead of putting it to nil add a random image with alpha set to 0 to have the same effect but not have any memory leaks?

Community
  • 1
  • 1
Octoshape
  • 1,131
  • 8
  • 26
  • I think the answer to your question is described in this post: [Symbolicating iPhone App Crash Reports][1] [1]: http://stackoverflow.com/questions/1460892/symbolicating-iphone-app-crash-reports – brad_roush Oct 10 '11 at 05:48
  • I was looking at that post but I don't really understand what to do since I am mainly a windows user and thus not used to Terminal and such things.. :-/ but I'll try.. – Octoshape Oct 10 '11 at 05:55
  • I really tried.. I archived the app, got the dSYM file, and the app file, got one of the crash logs from the simulator, and put them into a folder and tried that second answer to the question you posted, it doesn't work.. help please :/ – Octoshape Oct 10 '11 at 06:17
  • (b.t.w: cool a polyball 2011 app; switzerland?) – Jonas Schnelli Oct 10 '11 at 06:51
  • yes *blush*.. should've cut that one out.. – Octoshape Oct 10 '11 at 07:00

1 Answers1

0

It's not always easy to "read" crash reports. The two you sent does not show up any "own coded" methods.

And you have "EXC_BAD_ACCESS", so i would pretty much say: "it's a memory release/retain issue": You might release something of the UITableView to early.

Did you check that the UITableViewCell is proper autoreleased? Are all subviews and objects within the UITableViewCell on autorelease or at least not released to 0?

More details:

1) i would never create a UITableViewCell subclass by NIB/XIB. You loose a lot of performance. I recommend you to create the UITableViewCell subclass by coding. Remember: the deflating of XIB (xml) needs time and when you scroll through a UITableView there might ugly buckings.

2) for the memory issue you have: check this: How do you load custom UITableViewCells from Xib files? autorelease is not the right thing there.

Community
  • 1
  • 1
Jonas Schnelli
  • 9,965
  • 3
  • 48
  • 60
  • Hmm.. I'm using custom tableview cells, they all have labels and stuff that are on retain and simply released on "dealloc" .. would that cause a problem? I can post the code if you like – Octoshape Oct 10 '11 at 07:02
  • Im not 100% sure if it's a release/retain crash (but 95%, ;)). When you post some more code i can look at it. – Jonas Schnelli Oct 10 '11 at 07:46
  • the tableviewcell part: i'd like to see how you build your UITableViewCell and how you return it from the cellForRow hook – Jonas Schnelli Oct 10 '11 at 08:01
  • I added the code to the question.. I hope it's not too much to read through :) – Octoshape Oct 10 '11 at 11:01
  • 1) i would never create a UITableViewCell subclass by NIB/XIB. You loose a lot of performance. I recommend you to create the UITableViewCell subclass by coding. 2) for the memory issue you have: check this: http://stackoverflow.com/questions/540345/how-do-you-load-custom-uitableviewcells-from-xib-files autorelease is not the right thing there. – Jonas Schnelli Oct 10 '11 at 12:15
  • it still crashes.. :-/ I'll edit the code above to show you what I've changed.. I'm sorry, if this is too much work for you just let me know.. I'll get apple code level support then.. but thank you already for all your effort! – Octoshape Oct 10 '11 at 12:28
  • oh! the crash log changed.. and by the way it is not crashing when I open the tableview, it's crashing when I hit the back button and the tableview before is shown, or rather when this tableview gets deallocated judging from the new crash log.. I'll put the new one up, replacing the other two.. – Octoshape Oct 10 '11 at 12:34
  • it's still a release to much. somewhere you do release a already autorelease object. Double-/Tripplecheck. – Jonas Schnelli Oct 10 '11 at 12:58
  • I'll start deleting release messages and check until it stops crashing :-/ – Octoshape Oct 10 '11 at 13:06
  • (a chat would be a lot easier than commenting back and forth :D) – Octoshape Oct 10 '11 at 13:06
  • I can't find anything and the only difference to the other tableviews that are WORKING is that there's 2 types of cells in this one :-/ .. this is hard, and I'm running out of time – Octoshape Oct 10 '11 at 13:46
  • i had this problems also in the beginning. but after really understanding the memory management of objective-c if never had any issues. so maybe have a look at the memory management. it's necessary to understand release/autorelease/retain as well as alloc]init as well as convenience allocator. – Jonas Schnelli Oct 10 '11 at 13:52
  • I think the problem is that I'm using IB.. and I really do not understand how memory management connects to IB in terms of who is allocating and/or releasing what.. it's just so weird that in another tableview it simply works having the same code therein.. :-/ I found out I still had NSZombies in my scheme, so now it also crashes during xcode, which makes it easier to debug, and the line I get the crash at is always: `[UITableVieCell removeFromSuperView]` so somehow the cell seems to be already released when it shouldn't have been.. :-/ – Octoshape Oct 10 '11 at 14:04
  • it seems to be working .. :-/ but I'm not sure why.. and I don't know if I have leaks now .. will check with instruments reeeeal good.. – Octoshape Oct 10 '11 at 14:05
  • 60 leaks.. what I did is simply add [cell retain] after the cell = [topLevelObjects ..]; ...but it didn't crash! :) – Octoshape Oct 10 '11 at 14:19
  • Leaks means also that the App uses more and more memory and will be killed by the OS as soon as the footprint is to large. This will also looks like a crash from enduser perspective. I would say the problem has shifted in time. Maybe you bring the source code to the next cocoa head meeting at zurich. – Jonas Schnelli Oct 11 '11 at 07:48
  • ok I have found one bug .. my cellIdentifier in the custom cell NIB had a typo (cell with 3 "l") -.- .. so it wasn't reusing cells, and therefore crashed (what?) so that's fixed with the scrolling, but still whenever a TableView is deallocated that is using custom cells the app crashes on [UITableViewCell removeFromSuperView] :-/ the next cocoa head meeting is probably only after the PolyBall, so there would be no use :) – Octoshape Oct 11 '11 at 08:30
  • and to be quite honest I would be ashamed of the bad style in my code :D – Octoshape Oct 11 '11 at 08:30
  • Oh my .. I think I just found it .. can you check my question again? I'll edit some code there.. – Octoshape Oct 11 '11 at 08:39
  • coming to think of it this makes no sense to omit those releases in the dealloc method of the cell :-/ (check the question before reading this to see what I mean).. but it doesn't look like there are any leaks :-/ I'll just play around with it some more until I might find one.. – Octoshape Oct 11 '11 at 08:47
  • nevermind.. it's leaking .. I'll put this into a new question and accept your answer for this one for all your effort.. thank you so much again and who knows maybe we'll meet in Zurich some day.. I'll make sure to buy you a beer then ;) – Octoshape Oct 11 '11 at 08:56
  • I have found my error by accident .. I saw that the EXC_BAD_ACCESS happens in the dealloc method of the UITableViewCell when he is trying to release "favoritesImage" .. would you mind looking at a little sample code? I'll edit the question once more, it's a simple question about general memory management that would enhance my understanding greatly if you could answer it.. – Octoshape Oct 11 '11 at 13:53
  • Hi Octoshape We are far away from stackoverflow questions.. :) Let's look at it on a coocaheads meeting or try to form a proper question – Jonas Schnelli Oct 11 '11 at 14:24