Process Private Memory Usage Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
jNizM
Posts: 2681
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: Process Private Memory Usage

22 Mar 2019, 08:00

For 32-bit it should beif (NumGet(addr + 68, "ptr") = PID)
Will add 32-bit later too.. because I just work with 64-bit
[AHK] 1.1.33.02 x64 Unicode | [WIN] 10 Pro (Version 20H2) x64 | [GitHub] Profile
Donations are appreciated if I could help you
User avatar
jNizM
Posts: 2681
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: Process Private Memory Usage  Topic is solved

22 Mar 2019, 08:25

For 32- & 64-Bit

Code: Select all

MsgBox % GetWorkingSetPrivateSize(2580) " K"

GetWorkingSetPrivateSize(PID)
{
	if (DllCall("ntdll.dll\NtQuerySystemInformation", "int", 0x5, "ptr", 0, "uint", 0, "uint*", size) != 0) {
		size := VarSetCapacity(buf, size, 0)
		if (DllCall("ntdll\NtQuerySystemInformation", "int", 0x5, "ptr", &buf, "uint", size, "uint*", 0) != 0)
			return (ErrorLevel := 2) & 0
		addr := &buf
		while (addr) {
			if (NumGet(addr + 56 + A_PtrSize * 3, "ptr") = PID)
				return NumGet(addr + 8, "int64") // 1024
			if !(NumGet(addr + 0, "uint"))
				break
			addr += NumGet(addr + 0, "uint")
		}
	}
	return (ErrorLevel := 1) & 0
}
Full function -> https://www.autohotkey.com/boards/viewtopic.php?f=6&t=62989
[AHK] 1.1.33.02 x64 Unicode | [WIN] 10 Pro (Version 20H2) x64 | [GitHub] Profile
Donations are appreciated if I could help you
User avatar
hasantr
Posts: 780
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Process Private Memory Usage

23 Nov 2020, 09:02

Is there any way to empty the Private Memory?
SOTE
Posts: 1211
Joined: 15 Jun 2015, 06:21

Re: Process Private Memory Usage

23 Nov 2020, 17:14

hasantr wrote:
23 Nov 2020, 09:02
Is there any way to empty the Private Memory?
You might want to look at this thread:

https://autohotkey.com/board/topic/30042-run-ahk-scripts-with-less-half-or-even-less-memory-usage/
(Run AHK scripts with less (half or even less) memory usage)

Code: Select all

EmptyMem(PIDtoEmpty)
{   
    h:=DllCall("OpenProcess", "UInt", 0x001F0FFF, "Int", 0, "Int", PIDtoEmpty)
    DllCall("SetProcessWorkingSetSize", "UInt", h, "Int", -1, "Int", -1)
    DllCall("CloseHandle", "Int", h)
}
User avatar
hasantr
Posts: 780
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Process Private Memory Usage

24 Nov 2020, 02:22

SOTE wrote:
23 Nov 2020, 17:14
hasantr wrote:
23 Nov 2020, 09:02
Is there any way to empty the Private Memory?
You might want to look at this thread:

https://autohotkey.com/board/topic/30042-run-ahk-scripts-with-less-half-or-even-less-memory-usage/
(Run AHK scripts with less (half or even less) memory usage)

Code: Select all

EmptyMem(PIDtoEmpty)
{   
    h:=DllCall("OpenProcess", "UInt", 0x001F0FFF, "Int", 0, "Int", PIDtoEmpty)
    DllCall("SetProcessWorkingSetSize", "UInt", h, "Int", -1, "Int", -1)
    DllCall("CloseHandle", "Int", h)
}
Working Set is ok but Private Bytes is not shrunk. Maybe because it's impossible anyway.
Thansk.
User avatar
jNizM
Posts: 2681
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: Process Private Memory Usage

26 Nov 2020, 03:17

[AHK] 1.1.33.02 x64 Unicode | [WIN] 10 Pro (Version 20H2) x64 | [GitHub] Profile
Donations are appreciated if I could help you
User avatar
hasantr
Posts: 780
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Process Private Memory Usage

27 Nov 2020, 02:23

It did not work for Private Bytes. It has an effect on total memory but has no effect on Private Bytes. I have to radically change my application approach and find a different solution.
I was collecting hundreds of thousands of file paths in a single object. And when I needed I could compare quickly. But it has a heavy impact on memory. I will reduce the file paths to 8 bytes with the CRC32 function you made to save memory. I hope this is a logical way. If I thought the CRC16 would be sufficient for this job, my choice would be different.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], boiler, nacken012, newbieforever, Richfilth, roysubs, scriptors, T1ran1403, w64bit, wastercaliari and 87 guests