I did some experimenting with blitting Surfaces. I think the main memory leak I've been seeing is coming from the creation of a new SDLx::Rect every time the Rect coordinates are passed as [x, y, h, w]. By comparing 5 different blits, I was able to find out that by declaring the SDLx::Rect once and reusing it you can avoid this particular memory leak. I originally was working with a single background SDLx::Surface ($background) that has a white rectangle drawn on it. I would then blit this image to the SDLx::App ($app) during the Show Handler.
my $rect = SDLx::Rect->new(0,0,200,200); Tests $background->blit($app) = Steady memory utilization $background->blit($app, [0,0,200,200]) = Steady increase in memory utilization (~20K/second) $background->blit($app, [0,0,200,200], [0,0,200,200]) = Steady increase in memory utilization (~30K/second) $background->blit($app, $rect) = Steady memory utilization, dropped 4K after a minute or two $background->blit($app, $rect) = Steady memory utilization, shallow fluctuation of +/- 4K ever few minutes In the attached code, I've commented out 6 test lines (the blit($app) is duplicated for easy reference) at lines 32-34 & 46-48. I don't have any fancy way of testing the memory utilization, I just watched the Windows Task Manager for Memory changes on perl.exe (and counted seconds in my head...) Hopefully, I'll have time at work tomorrow to test this out with the Pong game from the SDL manual. This is kind of a roundabout way of getting there, but the extra code in creating the background surface and the rectangle really seem to help out.
MemoryTester.pl
Description: Binary data