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 448

Summary: SDL appears to have memory leaks
Product: SDL Reporter: Michael Buchoff <mbuchoff>
Component: mainAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED INVALID QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2    
Version: 1.2.11   
Hardware: x86   
OS: Linux   
Attachments: Output from valGrind

Description Michael Buchoff 2007-07-01 14:09:32 UTC
There is a program called valgrind that checks other programs for 

memory-leaks.  According to valgrind, the following program causes some 

memoryleaks between the two print statements:

#include <stdio.h>
#include <SDL/SDL.h>

int main(int argc, char *argv[]) {
    fprintf(stderr, "BEFORE");
    SDL_INIT(SDL_VIDEO | SDL_AUDIO);
    fprintf(stderr, "AFTER");

    return 0;
}

I compiled it with "g++-4.1 Main.cpp -lSDL".

I was curious if anyone else was having this issue.

I'm running Ubuntu 7.04 with an ATI Mobility Radeon x1400.  If there is any other information I can provide, please let me know.

In case someone reading this hasn't heard of valgrind, there is a VERY 

brief (i.e. 30-second) tutorial at:
  http://valgrind.org/docs/manual/QuickStart.html

Thank you in advance.

Michael Buchoff
Comment 1 Michael Buchoff 2007-07-01 14:35:23 UTC
Created attachment 217 [details]
Output from valGrind
Comment 2 Michael Buchoff 2007-07-01 14:38:22 UTC
Sorry, I was mistaken on the version number.  It should be 1.2.11.
Comment 3 Ryan C. Gordon 2007-07-01 15:08:05 UTC
glibc is known to have memory leaks and uninitialized data access in dlopen(), and xlib's XIM support (which we also use) is known to leak too...both leak even when the caller properly cleans up, as we do, and have had these issues reported by Valgrind for several years now without improvements from the original developers.

For what it's worth, they aren't major leaks, but they aren't bugs in SDL.

--ryan.

Comment 4 Michael Buchoff 2007-07-01 18:11:18 UTC
Thanks for the quick response.  Have these bugs been reported to glibc and xlib?