It was with no small amount of dismay that I recently noticed JustLooking was leaking tonnes of memory on my Leopard machine here at home. When developing the program, I put enormous amounts of time an energy into ensuring the program behaved well and didn’t leak. And yet, browsing through 75 photos from a trip to Hong Kong ground my 2GB system into the dirt in a hurry.
Upon further investigation, this appears to be a bug in Leopard—my Tiger machine has absolutely no leaking at all. The bug occurs specifically when using CoreImage and NSImage interchangeably. In effect, CoreImage works entirely on video card RAM, and NSImage works entirely in system RAM. The resizing method I use causes the system to copy some of that memory from the VRAM to the system RAM, and that code leaks a tonne at a time.
The good news is that you can fix this by just having CoreImage do the rotation. The bad news is that this is 100% incompatible with the fade effect transitions I use. So, right now, I have the choice between transitions or memory leaks. Or just using Tiger (for which there are a number of other great arguments).
One of things I had been looking at for JustLooking 3.2 was reworking exactly how I use CoreImage, filters, and the system’s loading code. It looks as though this work has just taken on added urgency.[Read Rest of Article]
I recently spent two weeks converting JustLooking, my Mac OS X Image Viewing program, from NSImage to CoreImage and friends. This experience was overall much easier than I expected, and I have learned a bunch of things, some of which might have been handy to have known in advance.
The good news is that it mostly lives up to the hype. The bad news is that it’s not without tricks and traps of its own. Here are some notes and comments.[Read Rest of Article]
I recently started working on an image viewing program for Mac OS X using Cocoa, and one of the features I decided to add was the ability to rotate images in 90° increments. I did some searching on the internet, and found a few things:
- Some other people who were struggling with the same thing and posted some code snippets.
- Code for a rotation function that supports arbitrary rotation and scaling.
- Apple Documentation on Drawing
Neither of the first two was exactly what I wanted—the first didn’t quite work, while the second was too complicated and, in order to support arbitrary rotation, created an NSImage object that was way too large.[Read Rest of Article]