Skip to content

Instantly share code, notes, and snippets.

@MangelMaxime
Created December 28, 2014 22:31
Show Gist options
  • Save MangelMaxime/fe8c8380c799eb7279fb to your computer and use it in GitHub Desktop.
Save MangelMaxime/fe8c8380c799eb7279fb to your computer and use it in GitHub Desktop.
FPS class Memory usage
override public function update(dt:Float) {
var now = Timer.stamp();
var memString : String;
this.times.push(now);
while (this.times[0] < now - 1) {
times.shift();
}
#if cpp
var usage : Float = convertToMB(Gc.memInfo(Gc.MEM_INFO_USAGE));
if (usage > this.memPeak)
this.memPeak = usage;
memString = "MEN : " + usage + "MB\nMEM Peak : " + this.memPeak + " MB\nMEM Reserved : " + convertToMB(Gc.memInfo(Gc.MEM_INFO_RESERVED)) + "MB";
#end
this.set_text("FPS : " + times.length + "\n" + memString);
}
private static function convertToMB (mem : Float) {
return Math.round(mem / 1024 / 1024 * 100) / 100;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment