#!/usr/bin/env gbs3 ' This script returns the memory really used by the system, the cache and swap being excluded. Function GetUsedMemory() AS Integer Dim sRes As String Dim aRes As String[] Dim cVal As New Collection Dim sVal As String Exec ["cat", "/proc/meminfo"] To sRes For Each sVal In Split(sRes, "\n", "", True) aRes = Split(sVal, " ", "", True) if aRes[0] = "Committed_AS:" then break endif cVal[Left$(aRes[0], -1)] = CInt(aRes[1]) Next Return cVal!MemTotal - cVal!MemFree - cVal!Buffers - cVal!Cached + cVal!SwapTotal - cVal!SwapFree - cVal!SwapCached End Print Subst("Used memory: &1 Kb", GetUsedMemory())