Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve max memory allocation on 32 bit #605

Merged
merged 2 commits into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/urh/util/SettingsProxy.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand All @@ -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)
2 changes: 1 addition & 1 deletion tests/test_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


class TestSimulator(QtTestCase):
TIMEOUT = 0.5
TIMEOUT = 1.0

def setUp(self):
super().setUp()
Expand Down