diff --git a/changedetectionio/flask_app.py b/changedetectionio/flask_app.py index b7a3e6673..40b1452e6 100644 --- a/changedetectionio/flask_app.py +++ b/changedetectionio/flask_app.py @@ -71,9 +71,13 @@ socketio_server = None CORS(app) # Super handy for compressing large BrowserSteps responses and others -FlaskCompress(app) -app.config['COMPRESS_MIN_SIZE'] = 4096 +# Flask-Compress handles HTTP compression, Socket.IO compression disabled to prevent memory leak +compress = FlaskCompress() +app.config['COMPRESS_MIN_SIZE'] = 2096 app.config['COMPRESS_MIMETYPES'] = ['text/html', 'text/css', 'text/javascript', 'application/json', 'application/javascript', 'image/svg+xml'] +# Use gzip only - smaller memory footprint than zstd/brotli (4-8KB vs 200-500KB contexts) +app.config['COMPRESS_ALGORITHM'] = ['gzip'] +compress.init_app(app) app.config['TEMPLATES_AUTO_RELOAD'] = False diff --git a/changedetectionio/realtime/socket_server.py b/changedetectionio/realtime/socket_server.py index d268aa986..ae96e772b 100644 --- a/changedetectionio/realtime/socket_server.py +++ b/changedetectionio/realtime/socket_server.py @@ -240,7 +240,10 @@ def init_socketio(app, datastore): async_mode=async_mode, cors_allowed_origins=cors_origins, # None means same-origin only logger=strtobool(os.getenv('SOCKETIO_LOGGING', 'False')), - engineio_logger=strtobool(os.getenv('SOCKETIO_LOGGING', 'False'))) + engineio_logger=strtobool(os.getenv('SOCKETIO_LOGGING', 'False')), + # Disable WebSocket compression to prevent memory accumulation + # Flask-Compress already handles HTTP response compression + engineio_options={'http_compression': False, 'compression_threshold': 0}) # Set up event handlers logger.info("Socket.IO: Registering connect event handler")