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

live mode result to file? #402

Closed leiwen83 closed 1 year ago

leiwen83 commented 1 year ago

Is there an existing proposal for this?

Is your feature request related to a problem?

Current memray live mode would direct its result to TUI, which is good, not friendly to the server monitoring.

Describe the solution you'd like

I'd like the live mode has an option that like direct live mode reporting to txt file, so that could be used to further checking.

Alternatives you considered

No response

godlygeek commented 1 year ago

What sort of format are you picturing that the text file should have?

leiwen83 commented 1 year ago

How about show like "top"? Just as: xxM location: /usr/xxx/xxx/xxxx.py:xxx xxM location: /usr/xxx/xxx/xxxx.py:xxx

godlygeek commented 1 year ago

I can see the advantage of having a way to monitor a live process from another script, but this doesn't seem like a good way to achieve that goal. The format you're proposing would give much less information than our current live mode display does, and parsing it would require figuring out where the records from one refresh cycle ended and records from the next started, so we'd still need some sort of additional delimiter between them.

In the long term we plan to expose an API that could be used to make custom reporters, and once we've done that, it would be reasonable for us also to expose a way to get allocation records from a running process like memray live does. In the meantime, we're not going to pursue this option.