leaks, leaks, leaks.

Ever since upgrading to 10.6, some of the xscreensaver modules leak like crazy. Not all of them, just some. But with those, it is so bad that if those savers have run for only a few hours, the machine takes minutes to come back to life as it swaps madly. The ScreenSaverEngine process is becoming truly gargantuan.

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);
    CGImageRelease (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?

Tags: , , , ,

Deep Sea Hardhat Diver #8

Previously, previously, previously.

Tags: , , ,

If knowing the unknowable is crazy... I don't want to be saved.


Tags: , , , ,