mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-01-24 13:39:09 +00:00
[PUBLIC PR] Fix a bug where the memory counter would overflow into the negatives (#662)
* get Float instead of Int in cpp (Float is 64-bit in so it works easier than Int64) * use Math.fround instead of Math.round --------- Co-authored-by: Karim Akra <144803230+KarimAkra@users.noreply.github.com>
This commit is contained in:
parent
66b103c650
commit
71947c581e
|
@ -36,7 +36,7 @@ class MemoryCounter extends TextField
|
|||
@:noCompletion
|
||||
#if !flash override #end function __enterFrame(deltaTime:Float):Void
|
||||
{
|
||||
var mem:Float = Math.round(MemoryUtil.getMemoryUsed() / BYTES_PER_MEG / ROUND_TO) * ROUND_TO;
|
||||
var mem:Float = Math.fround(MemoryUtil.getMemoryUsed() / BYTES_PER_MEG / ROUND_TO) * ROUND_TO;
|
||||
|
||||
if (mem > memPeak) memPeak = mem;
|
||||
|
||||
|
|
|
@ -48,11 +48,11 @@ class MemoryUtil
|
|||
* Calculate the total memory usage of the program, in bytes.
|
||||
* @return Int
|
||||
*/
|
||||
public static function getMemoryUsed():Int
|
||||
public static function getMemoryUsed():#if cpp Float #else Int #end
|
||||
{
|
||||
#if cpp
|
||||
// There is also Gc.MEM_INFO_RESERVED, MEM_INFO_CURRENT, and MEM_INFO_LARGE.
|
||||
return cpp.vm.Gc.memInfo(cpp.vm.Gc.MEM_INFO_USAGE);
|
||||
return cpp.vm.Gc.memInfo64(cpp.vm.Gc.MEM_INFO_USAGE);
|
||||
#else
|
||||
return openfl.system.System.totalMemory;
|
||||
#end
|
||||
|
|
Loading…
Reference in a new issue