[SDL] osx 10.6 woes

jon jon.rafkind at gmail.com
Sun Dec 12 17:59:15 PST 2010


On 12/11/2010 10:34 PM, jon wrote:
> On 12/11/2010 10:27 PM, Eric Wing wrote:
>> On 12/11/10, jon <jon.rafkind at gmail.com> wrote:
>>> I get these warnings at runtime when I run my program in OSX 10.6 with
>>> SDL 1.2.14
>>>
>>> 2010-12-11 21:29:31.762 paintown[55732:1507] ***
>>> __NSAutoreleaseNoPool(): Object 0x988eb0 of class
>>> NSWindowGraphicsContext autoreleased with no pool in place - just leaking
>>> 2010-12-11 21:29:32.025 paintown[55732:1507] ***
>>> __NSAutoreleaseNoPool(): Object 0x94e0c0 of class
>>> NSWindowGraphicsContext autoreleased with no pool in place - just leaking
>>> 2010-12-11 21:29:32.163 paintown[55732:1507] ***
>>> __NSAutoreleaseNoPool(): Object 0x98dba0 of class
>>> NSWindowGraphicsContext autoreleased with no pool in place - just leaking
>>>
>>> I tried using 3 methods of linking with SDL and it happens with all of them:
>>>   1. build SDL from source (.tar.gz)
>>>   2. install SDL with macports
>>>   3. install the SDL.framework from the .dmg
>>>
>>> These warnings come when my application is rendering to the screen in a
>>> separate thread. When my program loads some data I spawn a new thread to
>>> display some stuff to the screen (Loading...). I successfully use this
>>> method in Windows and Linux. Also I was using Allegro as a graphics
>>> backend until recently and rendering to a separate thread in OSX with
>>> Allegro worked just fine.
>>>
>>> So is this a bug in SDL or is rendering to the screen not allowed at
>>> all? I haven't narrowed down the code exactly to SDL_Flip() or anything,
>>> I can try that if no one is sure what exactly is the cause.
>>>
>>>
>> This is most likely because you are trying to draw in another thread.
>> Cocoa is very particular about its rules about what things can be done
>> in the non-main-thread and how you can do them. The first thing is
>> that each thread must have an autorelease pool if you use objects that
>> require an autorelease pool.
>>
>> The path of least resistance is to confine your drawing stuff to the
>> main thread.
>>
> Ok, I may rewrite my program so that I load things in a separate thread,
> but if I could slap an autorelease pool in there and have things work
> (and be reasonably robust) that would be the best option. Does anyone
> have any quick sample code on what sort of autorelease pool I need?
> Otherwise I'll google around and just try to figure it out.

For what its worth, I tried making my own allocation pool in the new
thread but I got a bus error. I bit the bullet and reorganized my code
so that loading resources occurs in a separate thread and the main
thread will display the loading message.



More information about the SDL mailing list