The Poker Copilot Blog

Tracking the development of Poker Copilot, Mac OS X software for poker analysis and statistics.

Friday, 19 June 2009

Finding Memory Leaks in Cocoa + Objective-C

I found and fixed a memory leak in Poker Copilot's HUD this afternoon. That's the satisfying way I like Fridays to end.

A small component of Poker Copilot is written in Objective-C and Cocoa, the standard tools for Mac OS X programs. (The rest of Poker Copilot is written in Java). In Java, all the memory is cleaned up automatically using Java's absolutely amazing and astounding garbage collector. For the first few years of Java, its garbage collector was primitive and caused long-running Java programs to freeze for some seconds from time to time. These days, however, the Java garbage collector is a programming work of art, working seamlessly, efficiently, and - most important of all - invisibly.

I've got used to that world. So moving into Objective-C, where I have to manually make sure memory is released seems like a jump back a decade or two in time. There is a garbage collector in Objective-C, but it produces code for Mac OS X 10.5+. When I tried to move Poker Copilot away from OS X 10.4 (Tiger) I had the virtual equivalent of an angry mob outside the front door, demanding justice for all. Well, for all the members of the angry mob!


And so, the Poker Copilot HUD had a memory leak. With the help of Xcode, Instruments, and this excellent blog post, I was able to find the leak and banish it forever. And hold of the angry mob.

Now back to the nice world of Java.

4 comments:

Anonymous said...

You will be able to use all the new developer feature from snow L for PC V.3
By the time PC V.3 is ready all the PowerPC macs will be very long in the tooth and most people will have to upgrade and you can be done with it.

Did you go to the developer show btw? or watch the keynote anyway?

KeithX said...

Was this a problem for version 1 or 2 or both?

Steve McLeod said...

@Anonymous:
Poker Copilot 3? Wow! That's getting ahead of things. :-)

@KeithX:
I found the problem in PCP 2, but it is almost certainly present in version 1, as well.

Anonymous said...

@Anonymous:
Poker Copilot 3? Wow! That's getting ahead of things. :-)

Well, thats what im saying. By the time your ready to release that, PowerPc macs will be old enough to where 90% of copilot users will be running on an intel mac.

 

Poker Copilot

Free 30 Day Trial

Only $69

Order risk free with our 30-day money back guarantee.

  • Poker tracking software for Mac OS X
  • Supports PokerStars, Winamax, Merge Network, Ongame Network
  • Analyses your opponents while you play
  • On-table HUD for Mac
  • Easy to use, easy to understand

Watch a demo of the major features of Poker Copilot