Memory-Safe Python Patterns
Implements battle-tested memory management patterns to prevent OOM kills and RSS creep in long-running Python processes.
This skill provides specialized guidance for writing Python scripts that must operate under strict memory constraints, such as systemd MemoryMax environments. It offers implementation patterns for explicit allocator purging (mimalloc and glibc malloc_trim), efficient HTTP response lifecycle management, and thread-safe resource reuse. It is an essential tool for developers building ETL pipelines, background workers, or high-throughput services where memory fragmentation and leaks often lead to production instability and SIGKILL events.
主要功能
01Optimized HTTP response and connection lifecycle management
0240 GitHub stars
03Explicit allocator purging for glibc and mimalloc
04Production-ready systemd service configuration templates
05Strategic GC cadence and manual object deletion patterns
06Thread-local connection reuse to prevent file descriptor exhaustion
使用场景
01Developing background workers running under strict systemd MemoryMax limits
02Diagnosing and fixing memory leaks and RSS creep in production Python services
03Building robust ETL pipelines that process large datasets in loops