yds12 / tarsila

Pixel art and spritesheet editor
Other
144 stars 7 forks source link

Fix free images causing serious memory leak issues #18

Closed crumblingstatue closed 1 year ago

crumblingstatue commented 1 year ago

Since macroquad doesn't automatically free textures, we need to do it ourselves, otherwise we risk serious memory leak. This causes eventual systemwide hang for me, as my video driver seems to be vulnerable to video memory leak, and eventually I run out of system memory as well.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage has no change and project coverage change: -0.02 :warning:

Comparison is base (5931823) 17.81% compared to head (451bc38) 17.79%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #18 +/- ## ========================================== - Coverage 17.81% 17.79% -0.02% ========================================== Files 32 32 Lines 3217 3220 +3 ========================================== Hits 573 573 - Misses 2644 2647 +3 ``` | [Impacted Files](https://codecov.io/gh/yds12/tarsila/pull/18?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=yds12) | Coverage Δ | | |---|---|---| | [tarsila/src/ui\_state.rs](https://codecov.io/gh/yds12/tarsila/pull/18?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=yds12#diff-dGFyc2lsYS9zcmMvdWlfc3RhdGUucnM=) | `0.00% <0.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=yds12). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=yds12)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

yds12 commented 1 year ago

Thanks, good catch! I didn't know that macroquad was not freeing the textures, will keep this in mind.

There's another PR I have planned to avoid memory exhaustion: the way we keep track of actions to be able undo is completely unoptimized (for example, if you resize the canvas I simply save the previous image in order to be able to recover it with CTRL+Z). I need to put a cap on the size of that data structure and start freeing some of the older action records. (That cap would be another configurable thing.)