2024-02-28 05:19:08 +00:00
|
|
|
package funkin.util.plugins;
|
|
|
|
|
|
|
|
import flixel.FlxBasic;
|
2024-03-14 01:47:15 +00:00
|
|
|
import funkin.util.TimerUtil;
|
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)
|
|
|
|
{
|
2024-03-14 01:47:15 +00:00
|
|
|
var perfStart:Float = TimerUtil.start();
|
2024-02-28 05:19:08 +00:00
|
|
|
funkin.util.MemoryUtil.collect(true);
|
2024-03-14 01:47:15 +00:00
|
|
|
trace('Memory GC took: ${TimerUtil.seconds(perfStart)}');
|
2024-02-28 05:19:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override function destroy():Void
|
|
|
|
{
|
|
|
|
super.destroy();
|
|
|
|
}
|
|
|
|
}
|