We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 870 - Using SheepShaver with SDL 1.2.14 leads to a bunch of memory leaks
Summary: Using SheepShaver with SDL 1.2.14 leads to a bunch of memory leaks
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 1.2.14
Hardware: All Mac OS X 10.6
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-31 07:55 UTC by Jean-Pierre
Modified: 2011-08-23 13:52 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jean-Pierre 2009-10-31 07:55:08 UTC
Every time the screen is refreshed (60 times per second at much), the console displays an error message:

31/10/09 12:52:59	SheepShaver-i386-SDL[7852]	*** __NSAutoreleaseNoPool(): Object 0x45ebd0 of class NSWindowGraphicsContext autoreleased with no pool in place - just leaking

Looking into SDL 1.2.14 source code, the Quartz 2D UpdateRects() function in SDL_QuartzVideo.m does indeed allocate an object of type NSWindowGraphicsContext, but SheepShaver's display thread is not the main one and has no AutoReleasePool allocated.

To fix this, I added  a 'CGContextRef wcg_context' field to the SDL_PrivateVideoData structure, Initialized it at the end of QZ_SetVideoWindowed():

        this->UpdateRects     = QZ_UpdateRects;
        this->LockHWSurface   = QZ_LockHWSurface;
        this->UnlockHWSurface = QZ_UnlockHWSurface;
        
+        wcg_context = (CGContextRef)
+            [[NSGraphicsContext graphicsContextWithWindow: qz_window]
+             graphicsPort];

And used this wcg_context field in the UpdateRects() function instead of [NSGraphicsContext graphicsContextWithWindow].
No more leak.

Best regards,

 - Jean-Pierre.
Comment 1 Ryan C. Gordon 2011-08-23 13:52:56 UTC
(Sorry, some of these SDL-1.2 bugs have been sitting open for a long time.)

The problem is that you're not supposed to do SDL video calls from anything but the main thread, even if it happens to work on some platforms.

That being said, I think this is fixed in hg changeset 8e0dd46ad0e0. Feel free to reopen the bug if it isn't (and if you still care; again, sorry for the long delay!).

--ryan.