How to determine available memory?

Is there a way to determine the amount of (physical preferred) memory available to my app regardless of the host OS/Platform?

Specifically, I’m working on a Module that theoretically should work everywhere Xojo supports targeting and I’m trying to determine a reasonable size for an I/O buffer and other similar situations?

Did you check SystemInformationMBS module?

I was looking for a built-in method. I assume by your reply that there isn’t one?

You could do shell commands and parse the result. AFAIK there is nothing built in.

Beatrix - what are the appropriate shell commands? Or at least a clue to what to “Google” for

@Bryan Dunphy — If you want to search on Google, try “how to determine wired memory on <the_system>” (it can also be “physical memory”)

On macOS, you can read the physicalMemory property of your own NSProcessInfo object.

This works for me:

MsgBox(Format(Runtime.MemoryUsed/1000,"###,###,###")+" K")

But this one I’ve never tested:

[code]Public Function HardwareRAMUsed() as integer
// Shell Create
Dim ShellCmd As Shell
ShellCmd = New Shell

// Get the Process Info and get the 6th Value
ShellCmd.Execute(“ps aux | grep '” + App.ExecutableFile.Name + “’ | grep -v ‘grep’ | awk ‘{print $6}’”)
Dim Bytes As Integer
Bytes = Val( ShellCmd.Result ) * 1024

// Shell Close
ShellCmd.Close

// Return the Bytes
Return Bytes
End Function[/code]