Skip to content

SDL_GetDisplayUsableBounds call would grow memory without freeing resources? (MacOS/SDL3) #12571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
qiming2 opened this issue Mar 17, 2025 · 1 comment

Comments

@qiming2
Copy link

qiming2 commented Mar 17, 2025

int main(void) {
        if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS)) {
		exit(1);
	}


        int display_count;
        SDL_DisplayID* displays = SDL_GetDisplays(&display_count);
        SDL_Rect r;
        while (true) {
            
            SDL_GetDisplayUsableBounds(displays[0], &r)
  
        }
        SDL_free(displays);
}

Hi SDL folks!

I found my application's memory growing unbounded at some point, and tracked down the issue that is caused by one of imgui function calling SDL_GetDisplayUsableBounds(displays[0], &r). It does not seem like we need to free anything with this call tho. (Currently only tested it on macOS)

Above is the minimum example to see the memory growing unbounded.

Using Xcode profiler, the call eventually calls into [visibleFrame], so I am not sure if this is SDL or Cocoa's problem. This is my first time filing issues. Thanks for any feedback on this!

@qiming2 qiming2 changed the title SDL_GetDisplayUsableBounds call would grow memory without freeing resources? (MacOS) SDL_GetDisplayUsableBounds call would grow memory without freeing resources? (MacOS/SDL3) Mar 17, 2025
slouken added a commit that referenced this issue Mar 18, 2025
@slouken
Copy link
Collaborator

slouken commented Mar 18, 2025

Fixed, thanks for the repro case!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants