Skip to content
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

Sound memory leak #628

Closed
andreymal opened this issue Aug 6, 2023 · 1 comment
Closed

Sound memory leak #628

andreymal opened this issue Aug 6, 2023 · 1 comment

Comments

@andreymal
Copy link

loop {
    load_sound("./sound.ogg").await?;
}

RAM is leaking.

Like with font atlas, I tried to implement Drop for Sound:

impl Drop for Sound {
    fn drop(&mut self) {
        if Arc::strong_count(&self.0) < 2 {
            self.0.delete(&get_context().audio_context.native_ctx);
        }
    }
}

and this fixed the leak (but I'm not sure if this solution is complete and/or correct because I don't even know why Arc is used here)

profan added a commit to profan/macroquad that referenced this issue Apr 30, 2024
* Fix issue with Audio leaking memory when loaded by adding a drop impl, reported in issue not-fl3#628
* Fix issue with Font Atlas leaking memory by adding a drop impl, reported in issue not-fl3#627
* Fix issue with RenderTarget leaking memory by adding a drop impl, reported in issue not-fl3#635
@not-fl3
Copy link
Owner

not-fl3 commented Sep 21, 2024

Hopefully fixed with #813

@not-fl3 not-fl3 closed this as completed Sep 21, 2024
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