Page 1 of 1

Free RAM in Windows

Posted: Fri Jan 30, 2026 2:30 am
by Randy Walker
A little something I picked up from Meta AI in WhatsApp And thought I should share:

Code: Select all

Procedure.s RAM()
Define mem.MEMORYSTATUSEX
mem\dwLength = SizeOf(MEMORYSTATUSEX)
If OpenLibrary(0, "kernel32.dll")
  CallFunction(0, "GlobalMemoryStatusEx", @mem)
  Ret$ = Str(mem\ullAvailPhys / (1024 * 1024)) + " MB free"
  CloseLibrary(0)
  ProcedureReturn ret$
EndIf
EndProcedure
Debug RAM()
You might want to do Debug (Val(RAM())/1024)*1000 instead.

ALSO SEE: viewtopic.php?p=282628#p282628

Re: Free RAM in Windows

Posted: Fri Jan 30, 2026 7:50 am
by Bisonte
You mean

Code: Select all

Debug Str(MemoryStatus(#PB_System_FreePhysical) / (1024 * 1024)) + " MB free"
without Windows API ? ;)

Re: Free RAM in Windows

Posted: Fri Jan 30, 2026 8:35 am
by Randy Walker
Bisonte wrote: Fri Jan 30, 2026 7:50 am You mean

Code: Select all

Debug Str(MemoryStatus(#PB_System_FreePhysical) / (1024 * 1024)) + " MB free"
without Windows API ? ;)
Hey!!!! There's another cool tip, Except for one thing. Does not agree with my Task Manager. Any ideas why?

Re: Free RAM in Windows

Posted: Fri Jan 30, 2026 9:19 am
by Fred
MemoryStatus() use also GlobalMemoryStatusEx(), so the results should be identical.

Re: Free RAM in Windows

Posted: Fri Jan 30, 2026 9:35 am
by Randy Walker
Fred wrote: Fri Jan 30, 2026 9:19 am MemoryStatus() use also GlobalMemoryStatusEx(), so the results should be identical.
Seems to be ok if I do this:

Code: Select all

Debug Str((MemoryStatus(#PB_System_FreePhysical) / 1024/1024)) + " MB free"