Skip to content

Commit 792d32d

Browse files
perf: revert preload.
1 parent dc9c4c9 commit 792d32d

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

apps/maxkb/settings/mem.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import threading
55
from maxkb.const import CONFIG
66
from common.utils.logger import maxkb_logger
7-
import tracemalloc
87

98
CURRENT_PID=os.getpid()
109
GC_THRESHOLD = (100, 5, 5)
@@ -16,23 +15,15 @@ def change_gc_threshold():
1615
gc.set_threshold(*GC_THRESHOLD)
1716
maxkb_logger.debug(f"(PID: {CURRENT_PID}) GC thresholds changed from {old_threshold}{GC_THRESHOLD}")
1817

19-
2018
def force_gc():
21-
snapshot = tracemalloc.take_snapshot()
22-
top_stats = snapshot.statistics('lineno')
23-
maxkb_logger.debug("[ Top 10 memory-consuming lines ]")
24-
for stat in top_stats[:10]:
25-
maxkb_logger.debug(stat)
2619
collected = gc.collect()
2720
maxkb_logger.debug(f"(PID: {CURRENT_PID}) Forced GC ({collected} objects collected)")
2821
threading.Timer(GC_INTERVAL, force_gc).start()
2922

30-
3123
def init_memory_optimization():
32-
tracemalloc.start()
3324
change_gc_threshold()
3425
force_gc()
3526
maxkb_logger.debug("(PID: {CURRENT_PID}) Memory optimization (GC tuning) started.")
3627

37-
if CONFIG.get("ENABLE_MEMORY_OPTIMIZATION", '0') == "1":
28+
if CONFIG.get("ENABLE_MEMORY_OPTIMIZATION", '1') == "1":
3829
init_memory_optimization()

0 commit comments

Comments
 (0)