Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2017-08

GlobalMemoryStatus is Windows only, how to get installed RAM on Linux ?

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Van Canneyt
to Landmesser John
Landmesser John wrote 10 lines
googled in vain ... ... and "TsmBios" ( -> Win/Linux https://github.com/RRUZ/tsmbios ) won't compile :-( So how to get Information about installed RAM on Linux for example? Ok, i could grep "hwinfo" or such in a terminal but thats not what i'm looking for.

Your best options is most likely to read /proc/meminfo and parse the result. It contains a wealth of information.

Michael.

Reply by email

Graeme Geldenhuys
to Michael Van Canneyt
Michael Van Canneyt wrote
Your best options is most likely to read /proc/meminfo and parse the result. It contains a wealth of information.

Just a side note:

/proc/meminfo is specific to Linux, and doesn't apply to other Unix-like operating systems like Solaris, FreeBSD etc.

For example, under FreeBSD you can execute the following command and read the results back.

   $ /sbin/sysctl hw.physmem
   hw.physmem: 34,272,751,616

..and similar for other hardware under FreeBSD:

   $ /sbin/sysctl hw.model
   hw.model: Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz

Also worthy noting that the sysctl command can be executed without root access, even though it lives in the 'sbin' directory. This is super handy.

Landmesser John, if you look in the OnGuard project in the source/onguard.pas unit, there is code for Windows, Linux and FreeBSD (latter is still limited info) that extracts such information. You are welcome to copy some of that code as you need it.

The OnGuard Git repository can be found in the link below, and the web interface also has a "download zip" option.

https://github.com/graemeg/onguard

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email