MemoryInfo
Shows info about memory via AutoHotkey
Source
MemoryInfo.ahk (GitHub)
Example
References
- GlobalMemoryStatusEx function (msdn)
- SetProcessWorkingSetSize function (msdn)
- EmptyWorkingSet function (msdn)
- GetNumberFormat function (msdn)
- ITaskbarList3 interface (msdn)
Contributing
- thanks to AutoHotkey Community
Questions / Bugs / Issues
Please report any bugs or issues here. Same for any questions.
Copyright and License
The Unlicense
MemoryInfo
MemoryInfo
Last edited by jNizM on 16 Feb 2015, 02:48, edited 12 times in total.
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: MemoryInfo
[GlobalMemoryStatusEx function / MEMORYSTATUSEX structure] (Update 2015-02-16)
PSAPI Functions
PSAPI Functions
Code: Select all
; ===============================================================================================================================
; Function......: GlobalMemoryStatusEx
; DLL...........: Kernel32.dll
; Library.......: Kernel32.lib
; U/ANSI........:
; Author........: jNizM
; Modified......:
; Links.........: https://msdn.microsoft.com/en-us/library/aa366589.aspx
; https://msdn.microsoft.com/en-us/library/windows/desktop/aa366589.aspx
; ===============================================================================================================================
GlobalMemoryStatusEx()
{
static MEMORYSTATUSEX, init := VarSetCapacity(MEMORYSTATUSEX, 64, 0) && NumPut(64, MEMORYSTATUSEX, "UInt")
if !(DllCall("kernel32.dll\GlobalMemoryStatusEx", "Ptr", &MEMORYSTATUSEX))
return DllCall("kernel32.dll\GetLastError")
return { 1 : NumGet(MEMORYSTATUSEX, 0, "UInt"), 2 : NumGet(MEMORYSTATUSEX, 4, "UInt")
, 3 : NumGet(MEMORYSTATUSEX, 8, "UInt64"), 4 : NumGet(MEMORYSTATUSEX, 16, "UInt64")
, 5 : NumGet(MEMORYSTATUSEX, 24, "UInt64"), 6 : NumGet(MEMORYSTATUSEX, 32, "UInt64")
, 7 : NumGet(MEMORYSTATUSEX, 40, "UInt64"), 8 : NumGet(MEMORYSTATUSEX, 48, "UInt64")
, 9 : NumGet(MEMORYSTATUSEX, 56, "UInt64") }
}
; ===============================================================================================================================
GlobalMemoryStatusEx := GlobalMemoryStatusEx()
MsgBox, % "GlobalMemoryStatusEx function`n"
. "MEMORYSTATUSEX structure`n`n"
. "Lenght:`t`t`t" GlobalMemoryStatusEx[1] "`n`n"
. "MemoryLoad:`t`t" GlobalMemoryStatusEx[2] " %`n`n"
. "TotalPhys:`t`t`t" GlobalMemoryStatusEx[3] " bytes`n"
. "AvailPhys:`t`t`t" GlobalMemoryStatusEx[4] " bytes`n`n"
. "TotalPageFile:`t`t" GlobalMemoryStatusEx[5] " bytes`n"
. "AvailPageFile:`t`t" GlobalMemoryStatusEx[6] " bytes`n`n"
. "TotalVirtual:`t`t" GlobalMemoryStatusEx[7] " bytes`n"
. "AvailVirtual:`t`t" GlobalMemoryStatusEx[8] " bytes`n`n"
. "AvailExtendedVirtual:`t`t" GlobalMemoryStatusEx[9]
/* C++ ==========================================================================================================================
BOOL WINAPI GlobalMemoryStatusEx( // UInt
_Inout_ LPMEMORYSTATUSEX lpBuffer // Ptr (64)
);
typedef struct _MEMORYSTATUSEX {
DWORD dwLength; // UInt 4 => 0
DWORD dwMemoryLoad; // UInt 4 => 4
DWORDLONG ullTotalPhys; // UInt64 8 => 8
DWORDLONG ullAvailPhys; // UInt64 8 => 16
DWORDLONG ullTotalPageFile; // UInt64 8 => 24
DWORDLONG ullAvailPageFile; // UInt64 8 => 32
DWORDLONG ullTotalVirtual; // UInt64 8 => 40
DWORDLONG ullAvailVirtual; // UInt64 8 => 48
DWORDLONG ullAvailExtendedVirtual; // UInt64 8 => 56
} MEMORYSTATUSEX, *LPMEMORYSTATUSEX;
============================================================================================================================== */
Last edited by jNizM on 16 Feb 2015, 07:49, edited 15 times in total.
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: MemoryInfo
I like it! Nice GUI too! I have made something similar.. But I've never released it...
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: MemoryInfo
Nice GUI, nice avatar, and nice formats of the post.
Re: MemoryInfo
@jNizM
If I were to use only one of them, which do you recommend the WMI or DLL version?
If I were to use only one of them, which do you recommend the WMI or DLL version?
Check out my scripts. (MyIpChanger) (ClipBoard Manager) (SavePictureAs)
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
All my scripts are tested on Windows 10, AutoHotkey 32 bit Ansi unless otherwise stated.
Re: MemoryInfo
System Calls (Dllcall) have way better performance than WMI, because WMI ("bloated") does the same but indirectly.DataLife wrote:@jNizM
If I were to use only one of them, which do you recommend the WMI or DLL version?
In fact, all programs do system calls. The fundementals of the operating system.
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
Re: MemoryInfo
I had the same question (which version to use under what circumstances?). Thanks for the script update and info.
Author of freeware Quick Access Popup, the powerful Windows folders, apps and documents launcher!
Now working on Quick Clipboard Editor
The Automator's Courses on AutoHotkey
Now working on Quick Clipboard Editor
The Automator's Courses on AutoHotkey
Re: MemoryInfo
what is clear memory function, and what does it do exactly when i press Clear Memory?
Re: MemoryInfo
It clears memory, that isn't free yet, but not used anymore.Guest10 wrote:what is clear memory function, and what does it do exactly when i press Clear Memory?
"Nothing is quieter than a loaded gun." - Heinrich Heine
Re: MemoryInfo
when i run MemoryInfo v0.1. the bars show yellow color bars not green as showcased at the top of the page. is the color of bars any indication of the amount of memory available, etc. and could go from green to yellow depending on the amount of memory and ratios, etc. (as i suspect)?
Re: MemoryInfo
yes...
Code: Select all
Used:
Green --> Yellow --> Orange --> Red
0-19% --> 20-39% --> 40-69% --> 70-100%
Free:
Red --> Orange --> Yellow --> Green
0-30% --> 31-50% --> 51-80% --> 81-100%
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: MemoryInfo
Update: v0.2
- Memory in percent
- Only DLL-Version left
- Memory in percent
- Only DLL-Version left
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: MemoryInfo
Update:
GlobalMemoryStatusEx function / MEMORYSTATUSEX structure (see Post 2 from me)
GlobalMemoryStatusEx function / MEMORYSTATUSEX structure (see Post 2 from me)
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: MemoryInfo
is this now the latest for the 2nd post script (AHK)?
Code: Select all
GlobalMemoryStatusEx(GMS = 1) {
VarSetCapacity(MEMORYSTATUSEX, 64, 0)
NumPut(64, MEMORYSTATUSEX)
DllCall("GlobalMemoryStatusEx", "ptr", &MEMORYSTATUSEX)
return, % (GMS = "0") ? NumGet(MEMORYSTATUSEX, 0, "Int")
: (GMS = "1") ? NumGet(MEMORYSTATUSEX, 4, "Int")
: (GMS = "2") ? Round((NumGet(MEMORYSTATUSEX, 8, "Int64") / 1024**2), 2)
: (GMS = "3") ? Round((NumGet(MEMORYSTATUSEX, 16, "Int64") / 1024**2), 2)
: (GMS = "4") ? Round((NumGet(MEMORYSTATUSEX, 24, "Int64") / 1024**2), 2)
: (GMS = "5") ? Round((NumGet(MEMORYSTATUSEX, 32, "Int64") / 1024**2), 2)
: (GMS = "6") ? Round((NumGet(MEMORYSTATUSEX, 40, "Int64") / 1024**2), 2)
: (GMS = "7") ? Round((NumGet(MEMORYSTATUSEX, 48, "Int64") / 1024**2), 2)
: (GMS = "8") ? NumGet(MEMORYSTATUSEX, 56, "Int")
: "FAIL"
}
MsgBox, 48, GlobalMemoryStatusEx, % "GlobalMemoryStatusEx function /`n"
. "MEMORYSTATUSEX structure`n`n"
. "Lenght:`t`t`t" GlobalMemoryStatusEx(0) "`n`n"
. "MemoryLoad:`t`t" GlobalMemoryStatusEx(1) " %`n`n"
. "TotalPhys:`t`t`t" GlobalMemoryStatusEx(2) " MB`n"
. "AvailPhys:`t`t`t" GlobalMemoryStatusEx(3) " MB`n`n"
. "TotalPageFile:`t`t" GlobalMemoryStatusEx(4) " MB`n"
. "AvailPageFile:`t`t" GlobalMemoryStatusEx(5) " MB`n`n"
. "TotalVirtual:`t`t" GlobalMemoryStatusEx(6) " MB`n"
. "AvailVirtual:`t`t" GlobalMemoryStatusEx(7) " MB`n`n"
. "AvailExtendedVirtual:`t`t" GlobalMemoryStatusEx(8) " MB`n"
Re: MemoryInfo
I updated the whole 2nd post, so yes
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: MemoryInfo
This is fantastic, jNizM. Thank you so much for sharing this. I plan to use your function to log memory usage on task machines and our server, and report when memory gets low.
- Mike
- Mike
Re: MemoryInfo v0.1
i love using the memory cleaning stuff but i have noticed that it sometimes bugs for me
It is not happening very often but if it happens the whole script (which makes use of this) crashs with the following errormsg:
It is not happening very often but if it happens the whole script (which makes use of this) crashs with the following errormsg:
errormsg
any ideas how to fix this?Re: MemoryInfo
Mine is 55% free and 45% used, yet both bars are green.jNizM wrote:Code: Select all
Used: Green --> Yellow --> Orange --> Red 0-19% --> 20-39% --> 40-69% --> 70-100% Free: Red --> Orange --> Yellow --> Green 0-30% --> 31-50% --> 51-80% --> 81-100%
Re: MemoryInfo v0.1
Your code looks like it uses the same criteria for both bars. Perhaps a copy/paste and didn't finish editing? Also, it looks like there are no breaks below 70%.
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 171 guests