pythonprofilers / memory_profiler

Monitor Memory usage of Python code
http://pypi.python.org/pypi/memory_profiler
Other
4.39k stars 380 forks source link

`tracemalloc` `backend` broken for `memory_usage` #402

Open ilan-gold opened 5 months ago

ilan-gold commented 5 months ago
from memory_profiler import memory_usage
memory_usage(lambda _: x, backend="tracemalloc")

gives

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ilangold/Projects/Theis/anndata/benchmarks/venv_mem/lib/python3.12/site-packages/memory_profiler.py", line 369, in memory_usage
    p = MemTimer(os.getpid(), interval, child_conn, backend,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ilangold/Projects/Theis/anndata/benchmarks/venv_mem/lib/python3.12/site-packages/memory_profiler.py", line 244, in __init__
    _get_memory(self.monitor_pid, self.backend, timestamps=self.timestamps,
  File "/Users/ilangold/Projects/Theis/anndata/benchmarks/venv_mem/lib/python3.12/site-packages/memory_profiler.py", line 212, in _get_memory
    raise RuntimeError(
RuntimeError: There is no access to source file of the profiled function

Env:

memory-profiler==0.61.0
Python 3.12.3 [Clang 15.0.0 (clang-1500.1.0.2.5)] on darwin