1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-11-10 16:55:17 +00:00
Funkin/source/funkin/util/plugins/MemoryGCPlugin.hx

38 lines
761 B
Haxe
Raw Normal View History

2024-02-28 05:19:08 +00:00
package funkin.util.plugins;
import flixel.FlxBasic;
import funkin.util.tools.TimerTools;
2024-02-28 05:19:08 +00:00
/**
* A plugin which adds functionality to press `Ins` to immediately perform memory garbage collection.
*/
class MemoryGCPlugin extends FlxBasic
{
public function new()
{
super();
}
public static function initialize():Void
{
FlxG.plugins.addPlugin(new MemoryGCPlugin());
}
public override function update(elapsed:Float):Void
{
super.update(elapsed);
if (FlxG.keys.justPressed.INSERT)
{
var perfStart:Float = TimerTools.start();
2024-02-28 05:19:08 +00:00
funkin.util.MemoryUtil.collect(true);
trace('Memory GC took: ${TimerTools.seconds(perfStart)}');
2024-02-28 05:19:08 +00:00
}
}
public override function destroy():Void
{
super.destroy();
}
}