Skip to main content

Advanced memory profiler for Python with live tracking and visual export.

Project description

PyPI Tests License

🧠 memprofilerx

memprofilerx is a modern, developer-friendly Python library to monitor memory usage in real time — with zero friction and pro-level insights.

Track, visualize, and analyze memory in your scripts, APIs, and large-scale apps with just one decorator.


🚀 Features

  • 🧪 @track_memory: monitor memory during function execution
  • 📊 Auto-export graphs (PNG)
  • 🧠 Optional analysis of live Python objects with gc
  • 🔥 @global_tracker: monitor the whole process (great for FastAPI, CLI, etc)
  • 📈 Graph generation with matplotlib
  • 🧩 Extensible via callback or future plugins

💾 Installation

pip install memprofilerx

Or using poetry:

poetry add memprofilerx

⚙️ Usage

1. Track a single function

from memprofilerx.tracker import track_memory

@track_memory(interval=1.0, analyze_gc=True)
def process_data():
    x = [i for i in range(10_000_000)]
    return "Done"

result = process_data()

print(result["memory_usage"])     # List of (timestamp, memory_in_MB)
print(result["live_objects"])     # GC summary (if enabled)

2. Track the full runtime of an app

from memprofilerx.tracker import global_tracker

@global_tracker(interval=1.0, export_png="memory.png")
def main():
    import time
    data = [i for i in range(10_000_000)]
    time.sleep(5)

main()

Generates:

  • 📄 memory.png: chart of memory usage over time

📈 Generate memory graph manually

from memprofilerx.reporter import plot_memory

data = [(0, 21.4), (1, 33.8), (2, 56.0)]
plot_memory(data, output_path="custom_graph.png")

🧠 Output Example

{
  "result": "Done",
  "memory_usage": [
    [0.0, 23.1],
    [1.0, 130.5],
    [2.0, 130.7]
  ],
  "live_objects": {
    "list": {"count": 10003, "total_size_kb": 400.2},
    "dict": {"count": 12000, "total_size_kb": 800.5}
  }
}

🔧 Roadmap

  • Memory tracking via decorator
  • Graph export (PNG)
  • GC object analysis
  • Global tracker
  • CLI: memx run my_script.py
  • Live chart (rich + curses)
  • Export to HTML or CSV
  • Integration with logging/Prometheus/Sentry

📄 License

MIT — use it freely, improve it openly.


✨ Contribute

Pull requests are welcome! If you have ideas for advanced tooling, CLI integration, or observability plugins — open an issue or fork away.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memprofilerx-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

memprofilerx-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file memprofilerx-0.1.0.tar.gz.

File metadata

  • Download URL: memprofilerx-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.4 Windows/11

File hashes

Hashes for memprofilerx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1ba223af4e9ce208aa32ff593a4a6eceb31bfe44187c9466dfc5333b8d8b2bc9
MD5 a614e830415b31b9d0ca2d406b5cd1df
BLAKE2b-256 2b3100f83175f227ecbfa70c8256cffa0cc9ff305e1a8fbb8554600e5cab31ff

See more details on using hashes here.

File details

Details for the file memprofilerx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: memprofilerx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.4 Windows/11

File hashes

Hashes for memprofilerx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18c1220477d6798b046e86912825575ba7ce87814f2ec45ea41dfff0e27d84ad
MD5 c23de1906736a54215f2fcc3873d2f89
BLAKE2b-256 7ff7d89e699bce3af3c3eb3c625a902b1ed0715ef6ad04c473ec0317f6113d81

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page