Allow to set "working set limit" on non-Windows OS

PR #16874.
This commit is contained in:
Chocobo1
2022-04-16 11:36:58 +08:00
committed by GitHub
parent 7377974731
commit bc937d38a2
8 changed files with 55 additions and 41 deletions

View File

@@ -45,6 +45,7 @@
#include "base/bittorrent/session.h"
#include "base/global.h"
#include "base/interfaces/iapplication.h"
#include "base/net/portforwarder.h"
#include "base/net/proxyconfigurationmanager.h"
#include "base/path.h"
@@ -285,6 +286,8 @@ void AppController::preferencesAction()
// Advanced settings
// qBitorrent preferences
// Physical memory (RAM) usage limit
data[u"memory_working_set_limit"_qs] = dynamic_cast<IApplication *>(QCoreApplication::instance())->memoryWorkingSetLimit();
// Current network interface
data[u"current_network_interface"_qs] = session->networkInterface();
// Current network interface address
@@ -738,6 +741,9 @@ void AppController::setPreferencesAction()
// Advanced settings
// qBittorrent preferences
// Physical memory (RAM) usage limit
if (hasKey(u"memory_working_set_limit"_qs))
dynamic_cast<IApplication *>(QCoreApplication::instance())->setMemoryWorkingSetLimit(it.value().toInt());
// Current network interface
if (hasKey(u"current_network_interface"_qs))
{

View File

@@ -48,7 +48,7 @@
#include "base/utils/version.h"
#include "api/isessionmanager.h"
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 9};
inline const Utils::Version<int, 3, 2> API_VERSION {2, 8, 10};
class APIController;
class AuthController;

View File

@@ -903,6 +903,14 @@
<fieldset class="settings">
<legend>QBT_TR(qBittorrent Section)QBT_TR[CONTEXT=OptionsDialog]&nbsp;(<a href="https://github.com/qbittorrent/qBittorrent/wiki/Explanation-of-Options-in-qBittorrent#Advanced" target="_blank">QBT_TR(Open documentation)QBT_TR[CONTEXT=HttpServer]</a>)</legend>
<table>
<tr>
<td>
<label for="memoryWorkingSetLimit">QBT_TR(Physical memory (RAM) usage limit:)QBT_TR[CONTEXT=OptionsDialog]&nbsp;<a href="https://wikipedia.org/wiki/Working_set" target="_blank">(?)</a></label>
</td>
<td>
<input type="text" id="memoryWorkingSetLimit" style="width: 15em;" title="QBT_TR(This option is less effective on Linux)QBT_TR[CONTEXT=OptionsDialog]">&nbsp;&nbsp;QBT_TR(MiB)QBT_TR[CONTEXT=OptionsDialog]
</td>
</tr>
<tr>
<td>
<label for="networkInterface">QBT_TR(Network interface:)QBT_TR[CONTEXT=OptionsDialog]</label>
@@ -1947,6 +1955,7 @@
// Advanced settings
// qBittorrent section
$('memoryWorkingSetLimit').setProperty('value', pref.memory_working_set_limit);
updateNetworkInterfaces(pref.current_network_interface);
updateInterfaceAddresses(pref.current_network_interface, pref.current_interface_address);
$('saveResumeDataInterval').setProperty('value', pref.save_resume_data_interval);
@@ -2346,6 +2355,7 @@
// Update advanced settings
// qBittorrent section
settings.set('memory_working_set_limit', $('memoryWorkingSetLimit').getProperty('value'));
settings.set('current_network_interface', $('networkInterface').getProperty('value'));
settings.set('current_interface_address', $('optionalIPAddressToBind').getProperty('value'));
settings.set('save_resume_data_interval', $('saveResumeDataInterval').getProperty('value'));