File tree Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Original file line number Diff line number Diff line change 1515 % memory() was added cross-platform to Octave ~ 2021.
1616 % Matlab memory() at least through R2025a is still Windows only.
1717 m = memory();
18- bytes = uint64(m .MemAvailableAllArrays );
18+
19+ bytes = m .MemAvailableAllArrays ;
20+
1921catch e
2022 switch e .identifier
2123 case {' MATLAB:memory:unsupported' , ' Octave:undefined-function' }
22- b = javaMethod(" getOperatingSystemMXBean" , " java.lang.management.ManagementFactory" );
24+ if stdlib .has_java()
25+ b = javaMethod(" getOperatingSystemMXBean" , " java.lang.management.ManagementFactory" );
2326
24- if stdlib .java_api() < 14
25- bytes = b .getFreePhysicalMemorySize();
27+ if stdlib .java_api() < 14
28+ bytes = b .getFreePhysicalMemorySize();
29+ else
30+ bytes = b .getFreeMemorySize();
31+ end
2632 else
27- bytes = b .getFreeMemorySize();
33+
34+ bytes = 0 ;
35+
2836 end
29- bytes = uint64(bytes );
3037 otherwise , rethrow(e )
3138 end
3239end
3340
41+ bytes = uint64(bytes );
42+
3443end
3544
3645% !assert(ram_free()>0)
Original file line number Diff line number Diff line change @@ -72,19 +72,24 @@ function test_cpu_arch(tc)
7272tc .verifyGreaterThan(strlength(arch ), 0 )
7373end
7474
75- function test_ram (tc )
75+ function test_ram_total (tc )
7676tc .assumeTrue(stdlib .has_dotnet() || stdlib .has_java())
7777
7878t = stdlib .ram_total();
7979tc .verifyGreaterThan(t , 0 )
8080tc .verifyClass(t , ' uint64' )
81+ end
82+
83+
84+ function test_ram_free(tc )
85+ tc .assumeTrue(ispc() || stdlib .has_java())
8186
8287f = stdlib .ram_free();
8388tc .verifyGreaterThan(f , 0 )
8489tc .verifyClass(f , ' uint64' )
8590
86- tc .verifyLessThanOrEqual(f , t )
91+ tc .verifyLessThanOrEqual(f , stdlib .ram_total(), ...
92+ " Free RAM should be less than or equal to total RAM" )
8793end
8894
8995end
90- end
You can’t perform that action at this time.
0 commit comments