Skip to content

Commit

Permalink
Add System.totalMemoryNumber
Browse files Browse the repository at this point in the history
(cherry picked from commit 2374bfc)
  • Loading branch information
ACrazyTown authored and ninjamuffin99 committed Oct 26, 2024
1 parent 8306425 commit ca25df7
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/openfl/system/System.hx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,20 @@ import hl.Gc;
**/
public static var totalMemory(get, never):Int;

// @:noCompletion @:dox(hide) @:require(flash10_1) public static var totalMemoryNumber (default, null):Float;
/**
The amount of memory (in bytes) currently in use that has been directly
allocated by Flash Player or AIR.
This property is expressed as a Float, which allows higher values than the
`System.totalMemory` property, which is of type Int.
This property does not return _all_ memory used by an OpenFL
application or by the application (such as a browser) containing Flash
Player content. The browser or operating system may consume other memory.
The `System.privateMemory` property reflects _all_ memory
used by an application.
**/
public static var totalMemoryNumber(get, never):Float;

/**
A Boolean value that determines which code page to use to interpret
Expand Down Expand Up @@ -277,6 +290,17 @@ import hl.Gc;
#end
}

@:noCompletion private static function get_totalMemoryNumber():Float
{
#if cpp
return Gc.memInfo64(cpp.vm.Gc.MEM_INFO_USAGE);
#elseif hl
return Gc.stats().currentMemory;
#else
return System.totalMemory;
#end
}

@:noCompletion private static function get_vmVersion():String
{
return "1.0.0";
Expand Down

0 comments on commit ca25df7

Please sign in to comment.