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 1689

Summary: Leaks galore in OS X Cocoa code.
Product: SDL Reporter: Edward Rudd <urkle>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: x86   
OS: Mac OS X 10.6   
Attachments: Patches for the mentioned leaks w/ fixes.
Updated patch that fixes the Cocoa_GetDisplayName method

Description Edward Rudd 2013-01-12 11:34:28 UTC
This is to document the various leaks I'm finding in the Cocoa code in SDL 2.

A few I'll attach patches for, others need discussion/rework as they are just done badly.


Ones not being fixed.

* SDL_cocoashape.m the Cocoa_SetWindowShape method

a pool is allocated but never released, along with the contents.  Note this method can be called multiple times (exposed via SDL_SetWindowShape)


Ones with fixes (in patch)

* SDL_cocoaevents.m

serviceMenu should be released

* SDL_cocoamessagebox.m

unreleased NSString allocated

* SDL_cococamodes.m

deviceInfo should be released

SDL_cocoavideo.m

* the alert should be released
Comment 1 Edward Rudd 2013-01-12 11:35:11 UTC
Created attachment 1015 [details]
Patches for the mentioned leaks w/ fixes.
Comment 2 Edward Rudd 2013-01-25 07:51:40 UTC
Created attachment 1027 [details]
Updated patch that fixes the Cocoa_GetDisplayName method
Comment 3 Sam Lantinga 2013-02-08 00:56:36 UTC
Patches applied, thanks!
http://hg.libsdl.org/SDL/rev/b0ca1571caf3

I think the shape leak is fixed with the recent @autorelease patch.

How did you find the leaks here?  Valgrind?
Comment 4 Edward Rudd 2013-02-08 08:03:14 UTC
actually I was looking through the analyzer output and then reading through the code..

Now, AFAIK @autorelease only works in 64bit only!! (Really bloody annoying).. unless that has changed in recent clang compilers
Comment 5 Sam Lantinga 2013-02-11 21:42:51 UTC
I backed out the @autorelease patch.  Do you want to do another pass on the analyzer?