diff --git a/src/urh/util/SettingsProxy.py b/src/urh/util/SettingsProxy.py index c04bc4432f..088016f17c 100644 --- a/src/urh/util/SettingsProxy.py +++ b/src/urh/util/SettingsProxy.py @@ -1,6 +1,7 @@ -import psutil import sys +import psutil + from urh import constants from urh.util.Formatter import Formatter from urh.util.Logger import logger @@ -12,6 +13,7 @@ class SettingsProxy(object): """ Centralize common settings operations """ + @staticmethod def get_receive_buffer_size(resume_on_full_receive_buffer: bool, spectrum_mode: bool) -> int: if SettingsProxy.OVERWRITE_RECEIVE_BUFFER_SIZE: @@ -27,10 +29,10 @@ def get_receive_buffer_size(resume_on_full_receive_buffer: bool, spectrum_mode: threshold = constants.SETTINGS.value('ram_threshold', 0.6, float) num_samples = threshold * (psutil.virtual_memory().available / 8) - # Do not let it allocate too much on 32 bit - if 8*num_samples > sys.maxsize // 2: - num_samples = sys.maxsize // (8 * 2) + # Do not let it allocate too much memory on 32 bit + if 8 * 2 * num_samples > sys.maxsize: + num_samples = sys.maxsize // (8 * 2 * 1.5) logger.info("Correcting buffer size to {}".format(num_samples)) - logger.info("Try to allocate receive buffer with size {0}B".format(Formatter.big_value_with_suffix(num_samples*8))) + logger.info("Allocate receive buffer with {0}B".format(Formatter.big_value_with_suffix(num_samples * 8))) return int(num_samples) diff --git a/tests/test_simulator.py b/tests/test_simulator.py index eac9b5d123..8c40780d64 100644 --- a/tests/test_simulator.py +++ b/tests/test_simulator.py @@ -21,7 +21,7 @@ class TestSimulator(QtTestCase): - TIMEOUT = 0.5 + TIMEOUT = 1.0 def setUp(self): super().setUp()