9

On .NET Framework we could use the TotalPhysicalMemory property from the ComputerInfo class like the code snippet below:

var totalPhysicalMemory = new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory;


I saw there was an API Proposal for this feature but don't think it is out yet.
Is there a work around for this .NET Core or maybe something that I might have missed out?

Prajnan Bhuyan
  • 415
  • 3
  • 11
  • I just checked how I was doing this in our codebase (in .NET framework, but I knew it isn't using VisualBasic components). Found that it's implemented by calling native GlobalMemoryStatusEx() function... – PMF Jan 10 '18 at 08:53
  • It looks as though (at least, right now), that TotalPhysicalMemory is .NET Framework and Mono specific (as per: https://apisof.net/catalog/Microsoft.VisualBasic.Devices.ComputerInfo.TotalPhysicalMemory). – Jamie Taylor Jan 10 '18 at 09:04
  • Possible duplicate of [How do you get total amount of RAM the computer has?](https://stackoverflow.com/questions/105031/how-do-you-get-total-amount-of-ram-the-computer-has) – Liam Feb 08 '18 at 09:52
  • [this](https://stackoverflow.com/a/105109/542251) is reliant om COM components so should work on Core and non-core. – Liam Feb 08 '18 at 09:54
  • I put some work into an implementation of `ComputerInfo` for .NET Standard on Linux, macOS, and Windows. https://github.com/NickStrupat/ComputerInfo – Nick Strupat Aug 28 '19 at 14:48
  • @NickStrupat super idea, it is in prerelease state, so does it work or is it no longer developed? – Lumo Jan 19 '21 at 15:36
  • @Lumo it works but I never did figure out the exact analogs for some of the metrics in Linux and macOS. – Nick Strupat Jan 20 '21 at 16:06

0 Answers0