Skip to content

Fix leak on failure to load renderable#407

Closed
Gusgo99 wants to merge 19 commits into
OneLoneCoder:masterfrom
Gusgo99:fix_leak_on_failure_to_load_renderable
Closed

Fix leak on failure to load renderable#407
Gusgo99 wants to merge 19 commits into
OneLoneCoder:masterfrom
Gusgo99:fix_leak_on_failure_to_load_renderable

Conversation

@Gusgo99

@Gusgo99 Gusgo99 commented Jun 19, 2025

Copy link
Copy Markdown
Contributor

The line removed had it's return value discarded. The return value is an owning raw pointer to a sprite just created by the function, so discarding it caused a leak. This code was used to test it:

bool OnUserUpdate(float fElapsedTime) override {
  renderable.Load("invalid_image.png"); // Attempt to load image that doesn't exist

  return true;
}

Before the change, a slow but steady increase in memory would happen with the previous code. After letting it run for a few minutes, the program reached 500 MB of used memory. After the change, no such increase in memory, and the same program takes 95 MB no matter how long it ran for.

@Gusgo99 Gusgo99 closed this Jun 19, 2025
@Gusgo99

Gusgo99 commented Jun 19, 2025

Copy link
Copy Markdown
Contributor Author

This PR was created to the wrong branch. New PR #408 was created to the correct branch.

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

Successfully merging this pull request may close these issues.

4 participants