Skip to content

Commit ca4b0fe

Browse files
laanwjPastaPastaPasta
authored andcommitted
Merge bitcoin#25320: util: modify Win32LockedPageAllocator to query windows for limit.
1cb42ae util: modify Win32LockedPageAllocator to query windows for limit (Oskar Mendel) Pull request description: This PR resolves a todo within the Win32LockedPageAllocator: `// TODO is there a limit on Windows, how to get it?`. The idea is to use the Windows API to get the limits like the posix based allocator does with `getrlimit`. I use [GetProcessWorkingSetSize](https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-getprocessworkingsetsize) to perform this task and fallback to `return std::numeric_limits<size_t>::max();` just like the posix implementation does. ACKs for top commit: sipsorcery: tACK 1cb42ae. Tree-SHA512: 7bdd8a57a4e64ee59d752417a519656e03526878462060753be4dce481eff4889fb5edc1bdbd575b707d9b2dfe255c87da9ef67baac97de9ac5e70a04c852081
1 parent edaf9cc commit ca4b0fe

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/support/lockedpool.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,10 @@ void Win32LockedPageAllocator::FreeLocked(void* addr, size_t len)
204204

205205
size_t Win32LockedPageAllocator::GetLimit()
206206
{
207-
// TODO is there a limit on Windows, how to get it?
207+
size_t min, max;
208+
if(GetProcessWorkingSetSize(GetCurrentProcess(), &min, &max) != 0) {
209+
return min;
210+
}
208211
return std::numeric_limits<size_t>::max();
209212
}
210213
#endif

0 commit comments

Comments
 (0)