diff --git a/codeflash/verification/pytest_plugin.py b/codeflash/verification/pytest_plugin.py index 1080ac3e2..c47f844de 100644 --- a/codeflash/verification/pytest_plugin.py +++ b/codeflash/verification/pytest_plugin.py @@ -6,6 +6,7 @@ # System Imports import logging import os +import platform import re import sys import time @@ -36,6 +37,19 @@ class UnexpectedError(Exception): pass +if platform.system() == "Linux" or platform.system() == "Darwin": + import resource + + # Get total system memory + total_memory = os.sysconf("SC_PAGE_SIZE") * os.sysconf( + "SC_PHYS_PAGES" + ) # Set memory limit to 80% of total system memory + memory_limit = int(total_memory * 0.8) + + # Set both soft and hard limits + resource.setrlimit(resource.RLIMIT_AS, (memory_limit, memory_limit)) + + def pytest_addoption(parser: Parser) -> None: """Add command line options.""" pytest_loops = parser.getgroup("loops")