As this didn't happen in 10.5, and the relevant code in xscreensaver hasn't changed, it's pretty tempting to point the finger at the fact that 10.6 switched from reference counting to garbage colection. But, that doesn't help me figure out how to fix it, really.
The problem (or at least, one particularly bad problem) seems to be under XCopyArea. Specifically, running the "Leaks" tool in the XCode "Instruments" app on the "Moire2" saver shows me a lot of leaking happening here:
- malloc ← CGDataProviderCreateWithData ← CGDataProviderCreateWithCopyOfData ← CGBitmapContextCreateImage ← XCopyArea
The code in question looks roughly like this (jwxyz.m around line 590):
- cgi = CGBitmapContextCreateImage (src->cgc);
CGContextDrawImage (dst->cgc, dst_rect, cgi);
So this suggests that CGImageRelease() is not properly releasing the DataProvider inside the CGImage. But when I do
- CGDataProviderRelease (CGImageGetDataProvider (cgi));
before the CGImageRelease(), I get warnings about reference counts going negative, so clearly that's wrong too.
I am at a loss about how to figure out what's actually going wrong here, or how to fix it. Any ideas?