Page 2 of 2

Re: Process Private Memory Usage

Posted: 22 Mar 2019, 08:00
by jNizM
For 32-bit it should beif (NumGet(addr + 68, "ptr") = PID)
Will add 32-bit later too.. because I just work with 64-bit

Re: Process Private Memory Usage  Topic is solved

Posted: 22 Mar 2019, 08:25
by jNizM
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

Re: Process Private Memory Usage

Posted: 22 Mar 2019, 10:15
by teadrinker
Fine!

Re: Process Private Memory Usage

Posted: 23 Mar 2019, 04:50
by Blue Kodiak
Totally Awesome.
:clap:

Re: Process Private Memory Usage

Posted: 23 Nov 2020, 09:02
by hasantr
Is there any way to empty the Private Memory?

Re: Process Private Memory Usage

Posted: 23 Nov 2020, 17:14
by SOTE
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)
}

Re: Process Private Memory Usage

Posted: 24 Nov 2020, 02:22
by hasantr
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.

Re: Process Private Memory Usage

Posted: 26 Nov 2020, 03:17
by jNizM

Re: Process Private Memory Usage

Posted: 27 Nov 2020, 02:23
by hasantr
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.