diff --git a/buildnumber.txt b/buildnumber.txt index fb2e329c..34d11379 100644 --- a/buildnumber.txt +++ b/buildnumber.txt @@ -1 +1 @@ -2060 \ No newline at end of file +2069 \ No newline at end of file diff --git a/source/funkin/game/Strum.hx b/source/funkin/game/Strum.hx index d93a1992..9b4718d0 100644 --- a/source/funkin/game/Strum.hx +++ b/source/funkin/game/Strum.hx @@ -16,14 +16,14 @@ class Strum extends FlxSprite { public var lastDrawCameras(default, null):Array = []; - public function getScrollSpeed(?note:Note) { + public inline function getScrollSpeed(?note:Note):Float { if (note != null && note.scrollSpeed != null) return note.scrollSpeed; if (scrollSpeed != null) return scrollSpeed; if (PlayState.instance != null) return PlayState.instance.scrollSpeed; return 1; } - public function getNotesAngle(?note:Note) { + public inline function getNotesAngle(?note:Note):Float { if (note != null && note.noteAngle != null) return note.noteAngle; if (noteAngle != null) return noteAngle; return angle; diff --git a/source/funkin/system/Main.hx b/source/funkin/system/Main.hx index f28f78c8..ce98ef95 100644 --- a/source/funkin/system/Main.hx +++ b/source/funkin/system/Main.hx @@ -129,6 +129,7 @@ class Main extends Sprite } public function loadGameSettings() { + MemoryUtil.init(); @:privateAccess FlxG.game.getTimer = getTimer; #if ALLOW_MULTITHREADING @@ -244,6 +245,7 @@ class Main extends Sprite Paths.assetsTree.clearCache(); + MemoryUtil.destroyFlixelZombies(); MemoryUtil.clearMajor(); } } diff --git a/source/funkin/utils/MemoryUtil.hx b/source/funkin/utils/MemoryUtil.hx index 22aea742..3b4087dc 100644 --- a/source/funkin/utils/MemoryUtil.hx +++ b/source/funkin/utils/MemoryUtil.hx @@ -12,6 +12,11 @@ import neko.vm.Gc; import openfl.system.System; class MemoryUtil { + public static function init() { + #if cpp + // cpp.NativeGc.addFinalizable(new MemoryUtil(), false); + #end + } public static function clearMinor() { #if (cpp || java || neko) Gc.run(false); @@ -50,4 +55,25 @@ class MemoryUtil { return 0; #end } + + private static var _nb:Int = 0; + private static var _nbD:Int = 0; + private static var _zombie:Dynamic; + + public static function destroyFlixelZombies() { + #if cpp + Gc.enterGCFreeZone(); + + while ((_zombie = Gc.getNextZombie()) != null) { + _nb++; + if (_zombie is flixel.util.FlxDestroyUtil.IFlxDestroyable) { + flixel.util.FlxDestroyUtil.destroy(cast(_zombie, flixel.util.FlxDestroyUtil.IFlxDestroyable)); + _nbD++; + } + } + Sys.println('Zombies: ${_nb}; IFlxDestroyable Zombies: ${_nbD}'); + + Gc.exitGCFreeZone(); + #end + } } \ No newline at end of file