diff options
author | smallsql <smallsql> | 2014-12-17 15:10:00 +0300 |
---|---|---|
committer | smallsql <smallsql> | 2014-12-17 15:10:00 +0300 |
commit | 07128757eb2a3b4596112dc2f44ead76aa04ae25 (patch) | |
tree | 1f3583167e6cbf10190e91d4bfb10da9babf1f83 | |
parent | 3f5ef75ffd70413f8e50804c79c885324f2fd39d (diff) |
implements OperatingSystemMXBean.getFreePhysicalMemorySize and OperatingSystemMXBean.getTotalPhysicalMemorySize
-rw-r--r-- | runtime/openjdk/sun.management.cs | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/runtime/openjdk/sun.management.cs b/runtime/openjdk/sun.management.cs index de71a26b..1270be4a 100644 --- a/runtime/openjdk/sun.management.cs +++ b/runtime/openjdk/sun.management.cs @@ -22,6 +22,7 @@ */ using System; +using System.Reflection; #if !FIRST_PASS using java.lang.management; #endif @@ -105,6 +106,29 @@ static class Java_sun_management_MemoryImpl static class Java_sun_management_OperatingSystemImpl { + private static long getComputerInfo(string property){ +#pragma warning disable 618 + Assembly asm = Assembly.LoadWithPartialName("Microsoft.VisualBasic"); +#pragma warning restore 618 + if (asm != null) + { + Type type = asm.GetType("Microsoft.VisualBasic.Devices.ComputerInfo"); + if (type != null) + { + try + { + ulong result = (ulong)type.GetProperty(property).GetValue(Activator.CreateInstance(type), null); + return (long)result; + } + catch (TargetInvocationException) + { + // Mono does not implement this property + } + } + } + throw new System.NotImplementedException(); + } + public static long getCommittedVirtualMemorySize0(object _this) { throw new System.NotImplementedException(); @@ -127,12 +151,12 @@ static class Java_sun_management_OperatingSystemImpl public static long getFreePhysicalMemorySize(object _this) { - throw new System.NotImplementedException(); + return getComputerInfo("AvailablePhysicalMemory"); } public static long getTotalPhysicalMemorySize(object _this) { - throw new System.NotImplementedException(); + return getComputerInfo("TotalPhysicalMemory"); } public static double getSystemCpuLoad(object _this) |