1 Commits

Author SHA1 Message Date
David Rodenkirchen 68c51a09f8 Analyze mem leak 2026-04-15 09:29:56 +02:00
7 changed files with 605 additions and 884 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+47 -4
View File
@@ -1,9 +1,15 @@
import logging import logging
import tracemalloc
import sys import sys
from pathlib import Path from pathlib import Path
from uuid import uuid4 from uuid import uuid4
import gc
import time
import threading
from collections import Counter
from datetime import datetime, UTC
from rio import App, Theme, Color, Font, ComponentPage, Session from rio import App, Theme, Color, Font, ComponentPage, Session
from from_root import from_root from from_root import from_root
@@ -13,9 +19,49 @@ from src.ezgg_lan_manager.helpers.LoggedInGuard import logged_in_guard, not_logg
from src.ezgg_lan_manager.services.LocalDataService import LocalData from src.ezgg_lan_manager.services.LocalDataService import LocalData
from src.ezgg_lan_manager.types.UserSession import UserSession from src.ezgg_lan_manager.types.UserSession import UserSession
tracemalloc.start(25)
logger = logging.getLogger("EzggLanManager") logger = logging.getLogger("EzggLanManager")
def log_object_summary():
gc.collect()
objs = gc.get_objects()
counter = Counter(type(obj).__name__ for obj in objs)
timestamp = datetime.now(UTC).isoformat()
with open("memory_objects.log", "a") as f:
f.write(f"\n=== {timestamp} ===\n")
f.write(f"Total objects: {len(objs)}\n")
for name, count in counter.most_common(25):
f.write(f"{name}: {count}\n")
def log_top_allocations():
snapshot = tracemalloc.take_snapshot()
top_stats = snapshot.statistics('lineno')
timestamp = datetime.now(UTC).isoformat()
with open("memory_allocations.log", "a") as f:
f.write(f"\n=== {timestamp} ===\n")
for stat in top_stats[:10]:
f.write(str(stat) + "\n")
def start_hourly_logger():
def loop():
while True:
log_object_summary()
log_top_allocations()
time.sleep(3) # 1 hour
t = threading.Thread(target=loop, daemon=True)
t.start()
if __name__ == "__main__": if __name__ == "__main__":
start_hourly_logger()
theme = Theme.from_colors( theme = Theme.from_colors(
primary_color=Color.from_hex("ffffff"), primary_color=Color.from_hex("ffffff"),
secondary_color=Color.from_hex("018786"), secondary_color=Color.from_hex("018786"),
@@ -27,10 +73,7 @@ if __name__ == "__main__":
corner_radius_small=0, corner_radius_small=0,
corner_radius_medium=0, corner_radius_medium=0,
corner_radius_large=0, corner_radius_large=0,
font=Font( font=Font(from_root("src/ezgg_lan_manager/assets/fonts/joystix.otf"))
regular=from_root("src/ezgg_lan_manager/assets/fonts/PixelOperatorMono.ttf"),
bold=from_root("src/ezgg_lan_manager/assets/fonts/PixelOperatorMono-Bold.ttf"),
)
) )
default_attachments: list = [LocalData(stored_session_token=None)] default_attachments: list = [LocalData(stored_session_token=None)]
default_attachments.extend(init_services()) default_attachments.extend(init_services())
@@ -47,8 +47,8 @@ class DesktopNavigation(Component):
return Card( return Card(
Column( Column(
Text(lan_info.name, align_x=0.5, margin_top=0.3, style=TextStyle(fill=self.session.theme.hud_color, font_size=2.5), font_weight="bold"), Text(lan_info.name, align_x=0.5, margin_top=0.3, style=TextStyle(fill=self.session.theme.hud_color, font_size=1.9)),
Text(f"Edition {lan_info.iteration}", align_x=0.5, style=TextStyle(fill=self.session.theme.hud_color, font_size=1.6), margin_top=0.3, margin_bottom=2, font_weight="bold"), Text(f"Edition {lan_info.iteration}", align_x=0.5, style=TextStyle(fill=self.session.theme.hud_color, font_size=1.2), margin_top=0.3, margin_bottom=2),
user_info_and_login_box, user_info_and_login_box,
*navigation, *navigation,
Text("Unsere Sponsoren", align_x=0.5, style=TextStyle(fill=self.session.theme.hud_color, font_size=0.9), margin_bottom=0.5, margin_top=1), Text("Unsere Sponsoren", align_x=0.5, style=TextStyle(fill=self.session.theme.hud_color, font_size=0.9), margin_bottom=0.5, margin_top=1),
@@ -1,7 +1,7 @@
from rio import Component, TextStyle, Color, Link, Button, Text from rio import Component, TextStyle, Color, Link, Button, Text
class DesktopNavigationButton(Component): class DesktopNavigationButton(Component):
STYLE = TextStyle(fill=Color.from_hex("02dac5"), font_size=1.2, font_weight="bold") STYLE = TextStyle(fill=Color.from_hex("02dac5"), font_size=0.9)
TEAM_STYLE = TextStyle(fill=Color.from_hex("F0EADE"), font_size=0.9) TEAM_STYLE = TextStyle(fill=Color.from_hex("F0EADE"), font_size=0.9)
label: str label: str
target_url: str target_url: str