clear more memory on cleanup

This commit is contained in:
2023-08-31 14:38:39 -06:00
parent 61fd472de9
commit 7a85e3f915
3 changed files with 33 additions and 4 deletions

View File

@@ -433,9 +433,21 @@
(hideDialog)
(hideLighting)
(when flxMovie.sceneKey
(let [scene (dictGet flxMovie.scenes flxMovie.sceneKey)]
(hideSet scene.set scene.camera ->:Void {})
(doFor prop scene.props
(hideProp prop.prop scene.camera ->:Void {}))
(doFor character scene.characters
(hideCharacter character scene.camera ->:Void {}))))
// Don't remove the sprite layers, which are added in new()
// TODO does this need to clear out currentSounds, etc? Probably
// clear out currentSounds and currentVoiceTracks
(set currentSounds [])
(currentSoundVolumes.clear)
(set currentVoiceTracks [])
(restoreOriginalVolumes.clear)
)
@@ -660,7 +672,7 @@
(savedVar :Float soundVolume 1.0)
(savedVar :Float masterVolume 1.0)
(prop :Array<FlxSound> currentSounds [])
(prop &mut :Array<FlxSound> currentSounds [])
(prop :Map<FlxSound,Array<Float>> currentSoundVolumes (new Map))
(method loadSound [path]
@@ -720,7 +732,7 @@
(savedVar :Float voiceVolume 1.0)
(prop :Array<FlxSound> currentVoiceTracks [])
(prop &mut :Array<FlxSound> currentVoiceTracks [])
(prop :Map<FlxSound,Function> restoreOriginalVolumes (new Map))
(method loadVoiceTrack [wavPath]

View File

@@ -9,4 +9,8 @@
([::colorStr ...coordStrs]
(let [points (groups coordStrs 2)]
(new FlxLightSource (for [x y] points (new FlxPoint (Std.parseFloat x) (Std.parseFloat y))) (Std.parseInt colorStr))))
(never otherwise)))
(never otherwise)))
(method destroy []
(whileLet [point (points.pop)]
(point.put)))

View File

@@ -528,6 +528,19 @@
// I hope this disposes of references to actors, props, sets, etc.:
(scenes.clear)
(propScales.m.clear)
(propsInScene.clear)
(overlaidPropsInScenes.clear)
(doFor m tweenedPositionsOfSpritesInScenes
(doFor p m
(p.put))
(m.clear))
(tweenedPositionsOfSpritesInScenes.clear)
(doFor =>key lightSourceList lightSources
(whileLet [lightSource (lightSourceList.elements.pop)]
(lightSource.destroy)))
(#when cpp
(cpp.vm.Gc.run true)
(cpp.vm.Gc.compact)))