mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Avoid integer overflow when calculating working set size
This commit is contained in:
parent
54327d579b
commit
c029122a8e
@ -799,7 +799,7 @@ void Application::shutdownCleanup(QSessionManager &manager)
|
|||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
void Application::applyMemoryWorkingSetLimit()
|
void Application::applyMemoryWorkingSetLimit()
|
||||||
{
|
{
|
||||||
const int UNIT_SIZE = 1024 * 1024; // MiB
|
const SIZE_T UNIT_SIZE = 1024 * 1024; // MiB
|
||||||
const SIZE_T maxSize = memoryWorkingSetLimit() * UNIT_SIZE;
|
const SIZE_T maxSize = memoryWorkingSetLimit() * UNIT_SIZE;
|
||||||
const SIZE_T minSize = std::min<SIZE_T>((64 * UNIT_SIZE), (maxSize / 2));
|
const SIZE_T minSize = std::min<SIZE_T>((64 * UNIT_SIZE), (maxSize / 2));
|
||||||
if (!::SetProcessWorkingSetSizeEx(::GetCurrentProcess(), minSize, maxSize, QUOTA_LIMITS_HARDWS_MAX_ENABLE))
|
if (!::SetProcessWorkingSetSizeEx(::GetCurrentProcess(), minSize, maxSize, QUOTA_LIMITS_HARDWS_MAX_ENABLE))
|
||||||
|
Loading…
Reference in New Issue
Block a user