SDL memory leak?

Hi, I 'm relatively new with SDL, working with it for a few weeks. I am
creating some kind of game and using SDL for video rendering. However
while debugging my application I’ve noticed that my memory usage was
constantly increasing in a steady pace of about 20K/sec. The following
test performed while having a scene of 19 objects without any animation
at all. Just a while (1) loop that keeps checking & rendering dirty
(invalidated) rectangles (none in this case, no animation).

First I thought I had a memory leak but after some extensive debugging
I’ve come to believe that I don’t and realized, surprisingly, that the
memory was increasing when entering one of the following function
SDL_BlitSurface() and SDL_UpdateRect(), (couldn’t determine which
exactly). My developing platform is WinXP and I’ve noticed that mem leak
in the debug version of my application (haven’t tried release version yet).

I’d like to ask if this is a known issue or having heard anything
similar before.

Thank you,
Themis

Hi, I 'm relatively new with SDL, working with it for a few weeks. I am
creating some kind of game and using SDL for video rendering. However
while debugging my application I’ve noticed that my memory usage was
constantly increasing in a steady pace of about 20K/sec. The following
test performed while having a scene of 19 objects without any animation
at all. Just a while (1) loop that keeps checking & rendering dirty
(invalidated) rectangles (none in this case, no animation).

First I thought I had a memory leak but after some extensive debugging
I’ve come to believe that I don’t and realized, surprisingly, that the
memory was increasing when entering one of the following function
SDL_BlitSurface() and SDL_UpdateRect(), (couldn’t determine which
exactly). My developing platform is WinXP and I’ve noticed that mem leak
in the debug version of my application (haven’t tried release version yet).

I’d like to ask if this is a known issue or having heard anything
similar before.

Thank you,
Themis

Most likely (99,999%) there’s a memory leak in your own code, so post it
here so that we can tell you where it is.

Koshmaar

I’d like to ask if this is a known issue or having heard anything
similar before.

No, it’s probably your code. I’ve used it for very graphic-intensive
games and SDL hasn’t caused me any memory leak (I’ve carefully designed
and implemented my own leaks :wink: )

--Gabriel-- 

Gabriel Gambetta
Mystery Studio - http://www.mysterystudio.com
Gabriel on Graphics - http://gabrielongraphics.blogspot.com

It’s most likely your own code. You’re probably not freeing the surface before
you load a new image into it. It’s a fairly common problem.> I’d like to ask if this is a known issue or having heard anything

similar before.

Thank you,
Themis

— Themistoklis Bourdenas
wrote:

Hi, I 'm relatively new with SDL, working with it
for a few weeks. I am
creating some kind of game and using SDL for video
rendering. However
while debugging my application I’ve noticed that my
memory usage was
constantly increasing in a steady pace of about
20K/sec. The following
test performed while having a scene of 19 objects
without any animation
at all. Just a while (1) loop that keeps checking &
rendering dirty
(invalidated) rectangles (none in this case, no
animation).

I’d like to ask if this is a known issue or having
heard anything
similar before.

I’m also fairly new to SDL and I had similar problems
to those you are describing. In my case I was wasn’t
freeing up surfaces after using them:

E.g. SDL_FreeSurface(surface_name);

May be something different in your case.

Guilherme___________________________________________________________
To help you stay safe and secure online, we’ve developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

Thank you for your comments. It is quite difficult to post the code in
my while loop as it is a lot of code spread in several files and it is
quite complicated (the application is a generic game engine) but I 'll
take another look to see if this is the case (not freeing surfaces)
though I doubt it because as I’ve said I have a still image rendering
over and over again (no animation) so I don’t load any new image on
surfaces or do anything dynamic on the scene right now (I’ve disabled
all of these actions).

Thanks anyway

Nick Stovall wrote:> It’s most likely your own code. You’re probably not freeing the surface before

you load a new image into it. It’s a fairly common problem.

I’d like to ask if this is a known issue or having heard anything
similar before.

Thank you,
Themis


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Themistoklis Bourdenas wrote:

Thank you for your comments. It is quite difficult to post the code in
my while loop as it is a lot of code spread in several files and it is
quite complicated (the application is a generic game engine) but I 'll
take another look to see if this is the case (not freeing surfaces)
though I doubt it because as I’ve said I have a still image rendering
over and over again (no animation) so I don’t load any new image on
surfaces or do anything dynamic on the scene right now (I’ve disabled
all of these actions).

Thanks anyway

Try valgrind. It is a little bit steep at the start to decipher its output
but it helps like nothing else.

.bill

If you’re using SDL_DisplayFormat, please keep in mind that it doesn’t convert
in place – it returns a NEW surface, which must be freed later.On December 6, 2005 07:16 am, Themistoklis Bourdenas wrote:

Thank you for your comments. It is quite difficult to post the code in
my while loop as it is a lot of code spread in several files and it is
quite complicated (the application is a generic game engine) but I 'll
take another look to see if this is the case (not freeing surfaces)
though I doubt it because as I’ve said I have a still image rendering
over and over again (no animation) so I don’t load any new image on
surfaces or do anything dynamic on the scene right now (I’ve disabled
all of these actions).

If you can run your code through a serious memory debugging tool, such
as Valgrind, it will tell you exactly where the leaked memory blocks
are allocated. This usually makes it trivial to find this kind of
bugs, whether they’re in your code or an external library.

If you’re on Windows or Mac, I don’t know what to use. Numega
BoundsChecker…? (Valgrind runs only on Linux/x86 and /AMD64, with
experimental support for Linux/PPC32 and some *BSD platforms.)

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Tuesday 06 December 2005 14.16, Themistoklis Bourdenas wrote:

Thank you for your comments. It is quite difficult to post the code
in my while loop as it is a lot of code spread in several files and
it is quite complicated (the application is a generic game engine)
but I 'll take another look to see if this is the case (not freeing
surfaces) though I doubt it because as I’ve said I have a still
image rendering over and over again (no animation) so I don’t load
any new image on surfaces or do anything dynamic on the scene right
now (I’ve disabled all of these actions).

If you’re on Windows or Mac, I don’t know what to use. Numega
BoundsChecker…? (Valgrind runs only on Linux/x86 and /AMD64, with
experimental support for Linux/PPC32 and some *BSD platforms.)

I can highly recommend the Numega/Compuware bounds checker. It may
however be out of your price range.

You could try this:

http://www.codeproject.com/tools/visualleakdetector.asp

  • Tom

If you’re on Windows (possibly/probably other systems too) then you can get
Fluid Studio’s Memory Manager [1] up and running in a couple minutes.

[1]
http://fluidstudios.com/pub/FluidStudios/MemoryManagers/Fluid_Studios_Memory_Manager.zipOn 12/6/05, David Olofson wrote:

On Tuesday 06 December 2005 14.16, Themistoklis Bourdenas wrote:

Thank you for your comments. It is quite difficult to post the code
in my while loop as it is a lot of code spread in several files and
it is quite complicated (the application is a generic game engine)
but I 'll take another look to see if this is the case (not freeing
surfaces) though I doubt it because as I’ve said I have a still
image rendering over and over again (no animation) so I don’t load
any new image on surfaces or do anything dynamic on the scene right
now (I’ve disabled all of these actions).

If you can run your code through a serious memory debugging tool, such
as Valgrind, it will tell you exactly where the leaked memory blocks
are allocated. This usually makes it trivial to find this kind of
bugs, whether they’re in your code or an external library.

If you’re on Windows or Mac, I don’t know what to use. Numega
BoundsChecker…? (Valgrind runs only on Linux/x86 and /AMD64, with
experimental support for Linux/PPC32 and some *BSD platforms.)

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Cheers,
Josh

Indeed numega is quite out of price for me, thank you though for vld. It
seems to be quite useful mem leak tool.

Tom Wilson wrote:> I can highly recommend the Numega/Compuware bounds checker. It may

however be out of your price range.

You could try this:

http://www.codeproject.com/tools/visualleakdetector.asp

  • Tom

SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I can also add that since version 6.0, VC++
also has support for debugging versions of
malloc/free and new/delete.

If you have unreleased memory blocks, they
will be dumped at the end of the execution.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/_core_using_c_run2dtime_library_debugging_support.asp

Cheers,
Paulo

Quoting Themistoklis Bourdenas :> Indeed numega is quite out of price for me, thank you though for vld. It

seems to be quite useful mem leak tool.

Tom Wilson wrote:

I can highly recommend the Numega/Compuware bounds checker. It may
however be out of your price range.

You could try this:

http://www.codeproject.com/tools/visualleakdetector.asp

  • Tom

SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


This message was sent using IMP, the Internet Messaging Program.