Added Memory Information - Free and Total memory for different platforms - #847
Added Memory Information - Free and Total memory for different platforms#847ChiragRupani wants to merge 8 commits into
Conversation
| { | ||
| if (RuntimeInformation.IsMacOSX()) | ||
| { | ||
| string sysctlContent = ProcessHelper.RunAndReadOutput("sysctl", "-a"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| { | ||
| if (RuntimeInformation.IsWindows()) | ||
| { | ||
| string content = ProcessHelper.RunAndReadOutput("wmic", "OS get TotalVisibleMemorySize, FreePhysicalMemory /Format:List"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| return null; | ||
| } | ||
|
|
||
| public static bool IsVistaAndAbove() => Version.Parse(RuntimeEnvironment.OperatingSystemVersion).Major >= 6; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| if (IsWindows() && IsVistaAndAbove()) | ||
| return MoSMemoryInfoProvider.MosMemoryInfo.Value; | ||
| if (IsWindows()) | ||
| return WmicMemoryInfoProvider.WmicMemoryInfo.Value; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| <ItemGroup> | ||
| <None Remove="Portability\Memory\TestFiles\SysctlMemory.txt" /> | ||
| <None Remove="Portability\Memory\TestFiles\VmStatMemory.txt" /> | ||
| </ItemGroup> |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| <ItemGroup> | ||
| <EmbeddedResource Include="Portability\Memory\TestFiles\SysctlMemory.txt" /> | ||
| <EmbeddedResource Include="Portability\Memory\TestFiles\VmStatMemory.txt" /> | ||
| </ItemGroup> |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
AndreyAkinshin
left a comment
There was a problem hiding this comment.
LGTM in general. Some minor changes are requested.
|
Resolved code review comments, for failing approval tests - total memory need to be of CI machine and free memory is dynamic. How it can be handled? |
You should replace it in |
| internal static class SysctlInfoProvider | ||
| { | ||
| internal static readonly Lazy<string> SysctlInfo = new Lazy<string>(Load); | ||
| private static string _sysctlInfo = null; |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
I have another concern about Linux. I don't think that it makes sense to print "Free" memory from The whole stats (some numbers have a small drift because I had different activities between measurements): I suggest using the htop format and print |
|
The same experiment on macOS. |
|
Linux: MacOS: |
|
@ChiragRupani, I guess we can print "Total/Used" on all operating systems because "Used memory" provides useful information not only on Windows but also on Linux and macOS. |
|
Its better to keep available memory as it is since available memory can be calculated as below: |
Linux: MemAvailable MacOS: Free + Inactive




Added Memory Information - Free and Total memory for different platforms, for #846 Add RAM to summary