2024-02-28 05:19:08 +00:00
|
|
|
package funkin.util.plugins;
|
|
|
|
|
|
|
|
import flixel.FlxBasic;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A plugin which adds functionality to press `Ins` to immediately perform memory garbage collection.
|
|
|
|
*/
|
2025-04-16 01:00:09 +00:00
|
|
|
@:nullSafety
|
2024-02-28 05:19:08 +00:00
|
|
|
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)
|
|
|
|
{
|
2025-06-06 05:53:31 +00:00
|
|
|
var perf = new funkin.util.logging.Perf();
|
2024-02-28 05:19:08 +00:00
|
|
|
funkin.util.MemoryUtil.collect(true);
|
2025-06-06 05:53:31 +00:00
|
|
|
perf.print();
|
2024-02-28 05:19:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override function destroy():Void
|
|
|
|
{
|
|
|
|
super.destroy();
|
|
|
|
}
|
|
|
|
}
|