bloomberg / memray

Memray is a memory profiler for Python
https://bloomberg.github.io/memray/
Apache License 2.0
13.36k stars 397 forks source link

--leaks flag used as module argument #514

Closed mrks-g closed 11 months ago

mrks-g commented 11 months ago

Is there an existing issue for this?

Current Behavior

Starting memray with the --leaks option does not work as expected on wsl2. python3 -m memray run -m server.start --leaks

the leaks-option is interpreted as a module attribute to server.start. How to use this option correctly?

Expected Behavior

I expected memray to start with the --leaks option.

Steps To Reproduce

ubuntu 22.04 python3 -m pip install memray python3 -m memray run -m server.start --leaks

Memray Version

1.11.0

Python Version

3.10

Operating System

Linux

Anything else?

No response

godlygeek commented 11 months ago

It needs to go before the -m, as everything after that is taken as the module to run and the arguments for that module.

python3 -m memray run --leaks -m server.start
mrks-g commented 11 months ago

Did not mentioned that I tried this already. The result is a unrecognized argument error: memray: error: unrecognized arguments: --leaks

godlygeek commented 11 months ago

Oh, my bad. Arguments to memray run do need to go before the -m, but --leaks is an argument for the reporter you're using, not for memray run

So, something like:

python3 -m memray run --trace-python-allocators -o output.bin -m server.start
python3 -m memray flamegraph --leaks output.bin