4

I've looked at some questions about profiling memory usage in Python programs, but so far haven't been able to get anything to work. My program must run as root (it opens a TUN/TAP device).

First, I tried heapy; unfortunately this didn't work for me. Every time my code tried to execute hpy().heap() the program froze. Not wanting to waste too much timed I decided to try valgrind.

I tried valgrind with massif:

# valgrind --tool=massif ./my_prog.py --some-options value

I think the issue is related to profiling Python programs. I tried my program (which runs as root) and no massif output file was generated. I also wasn't able to generate an output file with another Python program (which doesn't run as root). However, a simple C test program worked fine and produced the massif file.

What are the issues preventing Valgrind and massif from working correctly with Python programs?

2
  • 2
    does it make a difference if you call the python bin and pass the script as an argument? Commented Jun 20, 2011 at 16:12
  • @tMC, before I even read your comment I was thinking the same thing. It does in fact make a difference. Commented Jun 20, 2011 at 16:41

1 Answer 1

10

Instead of having the script launch the interpreter, directly calling it as a parameter to Valgrind solves the problem.

valgrind --tool=massif python my_script.py
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.