JohnOne Posted February 7, 2011 Posted February 7, 2011 (edited) MemGetStats() returns incorrect amount for me. Is there another more accurate method about? I have looked, and might have missed a post amid all the game threads associated with memory. MsgBox(0,"",_Mem()) Func _Mem() $a = MemGetStats() $a = Round($a[1] / 1024) Return $a & " MB" EndFunc EDIT: returns 992 for me or 1015 when / 1000, with 1GB ram. Edited February 7, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
AdmiralAlkex Posted February 7, 2011 Posted February 7, 2011 Why do you think it's wrong? What does task manager say you have?Is it the actual hardware you want? Try the .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
UEZ Posted February 7, 2011 Posted February 7, 2011 (edited) Try this: #AutoIt3Wrapper_UseX64=n MsgBox(0, "Physical Memory", "Physical Memory installed: " & Round(GetMemWMI() / 1024 ^2, 0) & " MB") Func GetMemWMI($srv = "localhost") Local $mem, $colItems, $colItem, $ping, $x $ping = Ping($srv) If $ping Then $objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $srv & "\root\cimv2") $colItems = $objWMIService.ExecQuery("Select Capacity from Win32_PhysicalMemory", "WQL", 0x30) If IsObj($colItems) Then For $objItem In $colItems $mem += $objItem.Capacity Next Return SetError(0, 0, $mem) Else Return SetError(2, 0, 0) EndIf Else Return SetError(1, 0, 0) EndIf EndFunc I'm sure that there is a kernel32.dll version flying around... Br, UEZ Edited February 7, 2011 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
JohnOne Posted February 7, 2011 Author Posted February 7, 2011 ask manager reports 991 MB Cheers UEZ, that seems to get it, speed is not really an issue against accuracy for me. Just had to change Round(GetMemWMI() / 1024 ^2, 0) & " GB") To Round(GetMemWMI() / 1024 ^3, 0) & " GB") Unless I have 1024 GB Anyway it reports 1 GB which is what I was after, just wondering if it will be ok on 64 bit OS. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
jvanegmond Posted February 7, 2011 Posted February 7, 2011 If task manager reports 991 MB, and your code in the OP reports 992 MB, you don't suspect a rounding error of some kind? Seems like a trivial thing to try before making a thread. MsgBox(0,"",_Mem()) Func _Mem() $a = MemGetStats() $a = Floor($a[1] / 1024) Return $a & " MB" EndFunc github.com/jvanegmond
JohnOne Posted February 7, 2011 Author Posted February 7, 2011 Yes, I did that and Ceiling, except I dont want what task manager reports, I want the amount of physical memory slotted into my memory banks, that is 1GB. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Tripredacus Posted February 7, 2011 Posted February 7, 2011 Yes, I did that and Ceiling, except I dont want what task manager reports, I want the amount of physical memory slotted into my memory banks, that is 1GB.You are best off reading out of the WMI then, as posted earlier. Twitter | MSFN | VGCollect
UEZ Posted February 7, 2011 Posted February 7, 2011 ask manager reports 991 MBCheers UEZ, that seems to get it, speed is not really an issue against accuracy for me.Just had to changeRound(GetMemWMI() / 1024 ^2, 0) & " GB")ToRound(GetMemWMI() / 1024 ^3, 0) & " GB")Unless I have 1024 GB Anyway it reports 1 GB which is what I was after, just wondering if it will be ok on 64 bit OS.GetMemWMI() / 1024 ^2 is MB and not GB It is also working properly when compiling it as x64 application.Br,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
JohnOne Posted February 7, 2011 Author Posted February 7, 2011 Great, thanks once again buddy. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
AdmiralAlkex Posted February 8, 2011 Posted February 8, 2011 Windows Vista SP1 and later also has the function GetPhysicallyInstalledSystemMemory (<-- link) in Kernel32.dllMsgBox(0, "Title", "GetPhysicallyInstalledSystemMemory = " & _GetPhysicallyInstalledSystemMemory()) Func _GetPhysicallyInstalledSystemMemory() $aRet = DllCall("Kernel32.dll", "int", "GetPhysicallyInstalledSystemMemory", "int*", "") If @error Then Return SetError(1, 0, 0) Return $aRet[1] EndFunc .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
JohnOne Posted February 8, 2011 Author Posted February 8, 2011 Thanks AdmiralAlkex, another good one, reports 1048576. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now