{"library":"mprofile","title":"mprofile: A Low-Overhead Memory Profiler","description":"mprofile is a low-overhead sampling memory profiler for Python, derived from heapprof, with an interface similar to tracemalloc. It attempts to give results comparable to tracemalloc, but uses statistical sampling to lower memory and CPU overhead. The sampling algorithm is the one used by tcmalloc and Golang heap profilers. The current version is 0.0.15, and it is compatible with Python >= 3.4.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install mprofile"],"cli":{"name":"mprofile","version":"sh: 1: mprofile: not found"}},"imports":["import mprofile"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import mprofile\nimport os\n\n# Start profiling with a recommended sample rate (128KB) for low overhead\nmprofile.start(sample_rate=128 * 1024)\n\n# Simulate some memory allocation\ndata = []\nfor i in range(100_000):\n    data.append(os.urandom(100)) # Allocate 100 bytes per iteration\n\n# Take a snapshot of memory usage\nsnapshot = mprofile.take_snapshot()\n\n# Print top 5 memory consuming lines and their statistics\nprint(\"Top 5 memory consuming lines:\")\nfor stat in snapshot.statistics(key_type='lineno')[:5]:\n    print(stat)\n\n# Stop profiling\nmprofile.stop()","lang":"python","description":"This quickstart demonstrates how to initialize `mprofile`, simulate some memory allocation, take a snapshot of the current memory usage, and print the top memory-consuming lines. The `sample_rate` is set to the recommended 128KB for a balance between overhead and precision.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"0.0.15","pypi_latest":"0.0.15","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":40,"avg_install_s":1.9,"avg_import_s":0,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"mprofile","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"mprofile","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.2,"import_time_s":0,"mem_mb":0.1,"disk_size":"21M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"mprofile","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"mprofile","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.7,"import_time_s":0,"mem_mb":0.1,"disk_size":"23M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"mprofile","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"mprofile","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.7,"import_time_s":0,"mem_mb":0.1,"disk_size":"15M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"mprofile","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"mprofile","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":3.1,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"mprofile","exit_code":1,"wheel_type":null,"failure_reason":"build_error","import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"mprofile","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":1.8,"import_time_s":0,"mem_mb":0.1,"disk_size":"20M"}]}}