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 5377 - Memory leak in SDL_RenderCopy
Summary: Memory leak in SDL_RenderCopy
Status: WAITING
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: 2.0.13
Hardware: x86_64 macOS 10.15
: P2 critical
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-02 10:24 UTC by Miguel Dorta
Modified: 2020-12-20 20:24 UTC (History)
0 users

See Also:


Attachments
The code that reproduces the memory leak when using SDL_RenderCopy (2.11 KB, text/x-csrc)
2020-12-02 10:26 UTC, Miguel Dorta
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Miguel Dorta 2020-12-02 10:24:01 UTC
I found a huge memory leak in SDL_RenderCopy when doing more than 100k calls.

Basically I’m drawing a grid with a lot of tiles.

If I draw in a loop this grid the memory stays at 120mb but if translate the coordinates of each tile with an offset, as soon as the grid stars to get drawn outside of the window viewport, then the memory grows and grows every frame taking all system memory.

As soon as the program stops moving the grid the memory usage stops increasing but the leaked memory is not released.

Also when the grid goes completely outside of the viewport the memory leak stops.

I attached a main.c file with the code to reproduce this bug.
Comment 1 Miguel Dorta 2020-12-02 10:26:16 UTC
Created attachment 4554 [details]
The code that reproduces the memory leak when using SDL_RenderCopy
Comment 2 Sam Lantinga 2020-12-20 20:24:37 UTC
I just tried to reproduce this on macOS and wasn't able to. Are you still seeing this with the latest snapshot?
http://www.libsdl.org/tmp/SDL-2.0.zip