File tree Expand file tree Collapse file tree 4 files changed +30
-15
lines changed Expand file tree Collapse file tree 4 files changed +30
-15
lines changed Original file line number Diff line number Diff line change 1111
1212function bytes = ram_free()
1313
14+ bytes = 0 ;
15+
1416try
1517 % memory() was added cross-platform to Octave ~ 2021.
1618 % Matlab memory() at least through R2025a is still Windows only.
2224 switch e .identifier
2325 case {' MATLAB:memory:unsupported' , ' Octave:undefined-function' }
2426 if stdlib .has_java()
25- b = javaMethod(" getOperatingSystemMXBean" , " java.lang.management.ManagementFactory" );
26-
27- if stdlib .java_api() < 14
28- bytes = b .getFreePhysicalMemorySize();
29- else
30- bytes = b .getFreeMemorySize();
31- end
32- else
33-
34- bytes = 0 ;
35-
27+ bytes = ram_free_java();
3628 end
3729 otherwise , rethrow(e )
3830 end
4234
4335end
4436
45- % !assert(ram_free()>0)
37+
38+ function bytes = ram_free_java()
39+
40+ b = javaMethod(" getOperatingSystemMXBean" , " java.lang.management.ManagementFactory" );
41+
42+ if stdlib .java_api() < 14
43+ bytes = b .getFreePhysicalMemorySize();
44+ else
45+ bytes = b .getFreeMemorySize();
46+ end
47+
48+ end
49+
50+ % !assert(ram_free() > 0)
Original file line number Diff line number Diff line change 3030
3131bytes = uint64(bytes );
3232
33-
3433end
3534
3635
Original file line number Diff line number Diff line change 3535
3636 - uses : ./.github/workflows/composite-install-matlab
3737
38+ - name : Matlab tell External Language Interface versions
39+ uses : matlab-actions/run-command@v2
40+ with :
41+ command : stdlib.platform_tell()
42+
3843 - name : Fortran FC
3944 if : runner.os == 'macOS'
4045 run : echo "FC=gfortran-14" >> $GITHUB_ENV
Original file line number Diff line number Diff line change @@ -87,9 +87,15 @@ function test_ram_free(tc)
8787f = stdlib .ram_free();
8888tc .verifyGreaterThan(f , 0 )
8989tc .verifyClass(f , ' uint64' )
90+ end
91+
92+ function test_ram_free_vs_total(tc )
93+ t = stdlib .ram_total();
94+ tc .assumeGreaterThan(t , 0 )
95+ f = stdlib .ram_free();
96+ tc .assumeGreaterThan(f , 0 )
9097
91- tc .verifyLessThanOrEqual(f , stdlib .ram_total(), ...
92- " Free RAM should be less than or equal to total RAM" )
98+ tc .verifyLessThanOrEqual(f , t , " Free RAM should be less than or equal to total RAM" )
9399end
94100
95101end
You can’t perform that action at this time.
0 commit comments