mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Fix smlua memory leaks (#606)
This commit is contained in:
parent
49c9a2d57e
commit
5314144e77
2 changed files with 7 additions and 11 deletions
|
|
@ -34,7 +34,6 @@ function handleMusic()
|
||||||
audioCurSeq = get_current_background_music()
|
audioCurSeq = get_current_background_music()
|
||||||
if audioMain then
|
if audioMain then
|
||||||
audio_stream_stop(audioMain)
|
audio_stream_stop(audioMain)
|
||||||
audio_stream_destroy(audioMain)
|
|
||||||
audioMain = nil
|
audioMain = nil
|
||||||
end
|
end
|
||||||
if bgms[curMap] and bgms[curMap].audio then
|
if bgms[curMap] and bgms[curMap].audio then
|
||||||
|
|
@ -76,7 +75,6 @@ function handleMusic()
|
||||||
else
|
else
|
||||||
if audioSpecial then
|
if audioSpecial then
|
||||||
audio_stream_stop(audioSpecial)
|
audio_stream_stop(audioSpecial)
|
||||||
audio_stream_destroy(audioSpecial)
|
|
||||||
audioSpecial = nil
|
audioSpecial = nil
|
||||||
if audioMain and audioMainPaused then
|
if audioMain and audioMainPaused then
|
||||||
audioMainPaused = false
|
audioMainPaused = false
|
||||||
|
|
|
||||||
|
|
@ -344,19 +344,17 @@ void smlua_update(void) {
|
||||||
audio_sample_destroy_pending_copies();
|
audio_sample_destroy_pending_copies();
|
||||||
|
|
||||||
smlua_call_event_hooks(HOOK_UPDATE);
|
smlua_call_event_hooks(HOOK_UPDATE);
|
||||||
|
|
||||||
// Collect our garbage after calling our hooks.
|
// Collect our garbage after calling our hooks.
|
||||||
// If we don't, Lag can quickly build up from our mods.
|
// If we don't, Lag can quickly build up from our mods.
|
||||||
/*lua_gc(L, LUA_GCSTEP, 1);
|
// Truth is smlua generates so much garbage that the
|
||||||
lua_gc(L, LUA_GCSTOP, 0);*/
|
// incremental collection fails to keep up after some time.
|
||||||
|
// So, for now, stop the GC from running during the hooks
|
||||||
// EDIT: uhh, it turns out that is not the case
|
// and perform a full GC at the end of the frame.
|
||||||
// if we only do incremental garbage collection,
|
|
||||||
// eventually the garbage will build up so much
|
|
||||||
// that the game slows to a crawl. Messing with
|
|
||||||
// the GC setting is what caused Arena to get worse
|
|
||||||
// over time.
|
|
||||||
// The real fix would be to make smlua produce less
|
// The real fix would be to make smlua produce less
|
||||||
// garbage.
|
// garbage.
|
||||||
|
lua_gc(L, LUA_GCSTOP, 0);
|
||||||
|
lua_gc(L, LUA_GCCOLLECT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void smlua_shutdown(void) {
|
void smlua_shutdown(void) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue