Share your advanced PureBasic knowledge/code with the community.
Randy Walker
Addict
Posts: 1208 Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA
Contact:
Post
by Randy Walker » Fri Jan 30, 2026 2:30 am
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
- - - - - - - - - - - - - - - -
Randy
I *never * claimed to be a programmer.
Bisonte
Addict
Posts: 1333 Joined: Tue Oct 09, 2007 2:15 am
Post
by Bisonte » 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 ?
P ureB asic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom
English is not my native language...
(I often use DeepL .)
Randy Walker
Addict
Posts: 1208 Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA
Contact:
Post
by Randy Walker » Fri Jan 30, 2026 8:35 am
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?
- - - - - - - - - - - - - - - -
Randy
I *never * claimed to be a programmer.
Fred
Administrator
Posts: 18499 Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:
Post
by Fred » Fri Jan 30, 2026 9:19 am
MemoryStatus() use also GlobalMemoryStatusEx(), so the results should be identical.
Randy Walker
Addict
Posts: 1208 Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA
Contact:
Post
by Randy Walker » Fri Jan 30, 2026 9:35 am
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"
- - - - - - - - - - - - - - - -
Randy
I *never * claimed to be a programmer.