Corbin Dunn and Louise Lovelle
Treehouse
Woodworking
Pictures/Photography
Videos
Machining
About
Search

Archive for October, 2007

Instruments on Leopard: How to debug those random crashes in your Cocoa app

Wednesday, October 31st, 2007

Update: Sept 9, 2009: Mac OS 10.6 Snow Leopard now has this feature built into Instruments! In Xcode, choose “Run -> Run with Performance Tool -> Zombies”, and repeat your steps that cause the crash. Easy as pie. Read on if you don’t have Snow Leopard…

Mac OS 10.5 Leopard has a great new developer app called Instruments.

It can easily be used to debug those “random crashers” in your application caused by too many -release or -autorelease calls. Let’s see how.

If you want to follow along, download this project: CrashTestDummy.zip

Open it up in Xcode.

The nib has two outlets in it: a basic NSObject called testObject and button setup to invoke the following code:

- (IBAction)buttonCrashTestAction:(id)sender {

// We are going to autorelease the testObject too many times..

[testObject autorelease];

}

So, we will hit the button a few times and we should get a crash. Compile the app with the Debug target. Start Instruments, and select the Object Allocations template:



Hit the purple “i” next to the instruments to bring up the inspector for it, and be sure to check “Record reference counts”, as seen below:





Cool. Click “Launch Executable” and select “Choose Executable”, and find CrashTestDummy.app from the built directory.





While you have the Open Panel up, add the environment variable NSZombieEnabled and set it to YES (sort of an optional step):




Hit Open, if you haven’t already done so.


Hit “Record” in instruments, which will start the app, and click the “Crash Test” button a few times until the app crashes.


Alright! Fire up Console.app and look for a line like this:



The important part is the address, 0×150d40, in this case.


In Instruments, move the mouse to the right of “All Allocations” and a little triangle appears:




Click on it to see all the allocations.

In the lower right hand corner of instruments click on the magnifying glass in the NSSearchField and select “Address”:



Type in your address, and you should see all allocations at that address:



Now, why so many? Well, addresses are reused. Chances are, the last allocation is your object, and sure enough, it is, since we know we are over releasing an NSObject instance. Click on that item, and you’ll see the history for it. Scroll to the bottom to see just the history for that NSObject:



Now! You should be able to figure out which release probably shouldn’t be there. We know it is #19 from our demo, but sometimes it isn’t that easy to figure out. Select #19’s row and then click the little gray arrow to next to its address (or whatever yours is), and then click on this button at the bottom of instruments to show the stack trace / extended detail:



You can then see when that “bad release” happened. Click on the thumb below for a full size screen shot of it.




Ahh! Way cool. Of course, this was a simple and easy test case.


Happy debugging :)


corbin

New Leopard user features – Open and Save Panels

Tuesday, October 30th, 2007

Leopard, the new Mac OS 10.5, is out!

There are a lot of new features, but not everything is mentioned on the features page. Here are some of the cool “power user” features which you may not know about:

The Open and Save Panel (implemented in Cocoa, also known as the NSSavePanel and NSOpenPanel)

1. There is a new Icon View mode with options:

However, the way to change the icon size to be small (as seen above) isn’t obvious. Click and hold down on the icon view segmented cell and a popup will occur:

2. You can now insert items in the panel (and Finder) “side bar” by drag and dropping directly from the views (you couldn’t do this on Tiger!) You can also rearrange or remove items.

3. When you have an item selected, cmd-r will “reveal” it in Finder

4. When you have an item selected, cmd-i will give the Finder “info” window.

5. If you perform a search, you can save the search (just like in Finder). In addition, you can save it just for that application:

…and it appears in a special sidebar section for just that app (to remove it, drag it out):

That’s it for now. 5 new features not even included in the top 300!



In the house…

Wednesday, October 17th, 2007

Great picture from Hans from last weekend:

(that’s me on Louise’s silk)

California Mountain Unicyle Weekend – THIS WEEKEND! Oct 12-14th, 2007, Santa Cruz.

Monday, October 8th, 2007

California Mountain Unicyle Weekend – THIS WEEKEND! Oct 12-14th, 2007, Santa Cruz.

http://www.unicycling.com/muni/2007/

Go to the website, and print out the form. You should come! The “big day” is saturday, and that will be the coolest.

New RADIOHEAD album. How much? It’s up to you.

Monday, October 8th, 2007

I *totally* support artists like radiohead that are going away from those damn record labels and selling their music online. What’s even better is when they do this when you click on the ? next to the price:

Sweet. I totally will give them money since I could just put a price of 0 and give it for free. Unfortunately, it doesn’t work on my mac when I go to fill out my CC info:

I emailed them. Hopefully they will fix this.

Anyways, download it, and give them a few pounds.

Cool wooden bike

Thursday, October 4th, 2007

Back when we rode Strawberry Fields Forever in May of ‘07, I took some pictures of a wooden/bamboo bike at Calfree’s shop.

the coolest part was the horns! Man. I want this bike. Sorry about the quality of the pictures; i was moving the phone too much.

Walle teaser!! New pixar film..

Tuesday, October 2nd, 2007

It is here: http://www.pixar.com/theater/trailers/walle/walle_t1_640.html

And… http://gizmodo.com/gadgets/trailers/second-wall+e-trailer-hits-the-internet-305889.php

Super! looks great.

http://disney.go.com/disneypictures/wall-e/

Project Hutchinson: Stained deck! (well, some of it)

Monday, October 1st, 2007

Louise and I stained a lot of the deck last weekend. I did most all the railings on Saturday/Sunday, and on Sunday afternoon we did the planks together (I sprayed while she brushed). Looks GREAT!

Click on pics for fullsize

I’m going to do the house soon….


(c) 2008-2009 Corbin Dunn

Corbin’s Treehouse is powered by WordPress. Made on a Mac.

Entries (RSS) and Comments (RSS).

18 queries. 0.345 seconds.