Skip to content

Commit

Permalink
Update openhands/runtime/action_execution_server.py
Browse files Browse the repository at this point in the history
Co-authored-by: Graham Neubig <[email protected]>
  • Loading branch information
xingyaoww and neubig authored Feb 11, 2025
1 parent ac5ee21 commit e64f477
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions openhands/runtime/action_execution_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,20 @@ def __init__(
self.last_execution_time = self.start_time
self._initialized = False

# Initialize memory monitor with configurable limits
# Get available system memory
total_memory_gb = psutil.virtual_memory().total / (
1024 * 1024 * 1024
) # Convert to GB
self.max_memory_gb = int(max(0.5, total_memory_gb - 1.0))
# Reserve 1GB as head room, minimum of 0.5GB
logger.info(
f'Total memory: {total_memory_gb}GB, setting limit to {self.max_memory_gb}GB (reserved 1GB for action execution server, minimum 0.5GB)'
)
if _override_max_memory_gb := os.environ.get('RUNTIME_MAX_MEMORY_GB', None):
self.max_memory_gb = int(_override_max_memory_gb)
logger.info(
f'Setting max memory to {self.max_memory_gb}GB (override by RUNTIME_MAX_MEMORY_GB environment variable)'
f'Setting max memory to {self.max_memory_gb}GB (according to the RUNTIME_MAX_MEMORY_GB environment variable)'
)
else:
# Get available system memory
total_memory_gb = psutil.virtual_memory().total / (
1024 * 1024 * 1024
) # Convert to GB
self.max_memory_gb = int(max(0.5, total_memory_gb - 1.0))
# Reserve 1GB as head room, minimum of 0.5GB
logger.info(
f'Total memory: {total_memory_gb}GB, setting limit to {self.max_memory_gb}GB (reserved 1GB for action execution server, minimum 0.5GB)'
)

@property
Expand Down

0 comments on commit e64f477

Please sign in to comment.