Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Fixed memory counter displaying negative numbers #2713

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/funkin/ui/debug/MemoryCounter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions source/funkin/util/MemoryUtil.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading