diff --git a/frappe/__init__.py b/frappe/__init__.py index b3a5c54fa5..fd77930816 100644 --- a/frappe/__init__.py +++ b/frappe/__init__.py @@ -53,12 +53,8 @@ local = Local() cache = None STANDARD_USERS = ("Guest", "Administrator") -_dev_server = int(sbool(os.environ.get("DEV_SERVER", False))) _qb_patched = {} -re._MAXCACHE = ( - 50 # reduced from default 512 given we are already maintaining this on parent worker -) - +_dev_server = int(sbool(os.environ.get("DEV_SERVER", False))) _tune_gc = bool(sbool(os.environ.get("FRAPPE_TUNE_GC", True))) if _dev_server: @@ -2450,3 +2446,6 @@ if _tune_gc: # everything else. g0, g1, g2 = gc.get_threshold() # defaults are 700, 10, 10. gc.set_threshold(g0 * 10, g1 * 2, g2 * 2) + +# Remove references to pattern that are pre-compiled and loaded to global scopes. +re.purge() diff --git a/frappe/app.py b/frappe/app.py index cdb5d6ad21..137165c1e9 100644 --- a/frappe/app.py +++ b/frappe/app.py @@ -4,6 +4,7 @@ import gc import logging import os +import re from werkzeug.exceptions import HTTPException, NotFound from werkzeug.local import LocalManager @@ -428,6 +429,9 @@ def serve( ) +# Remove references to pattern that are pre-compiled and loaded to global scopes. +re.purge() + # Both Gunicorn and RQ use forking to spawn workers. In an ideal world, the fork should be sharing # most of the memory if there are no writes made to data because of Copy on Write, however, # python's GC is not CoW friendly and writes to data even if user-code doesn't. Specifically, the