vprof icon indicating copy to clipboard operation
vprof copied to clipboard

`import` does not work with memory profiler

Open ahuigo opened this issue 7 years ago • 1 comments

Description

import mod do not work with memory profile.

How to reproduce

mod.py: print("I'm mod") main.py: import mod

Actual results
$ vprof -c cm "main.py"
Running MemoryProfiler...
I'm mod
Running FlameGraphProfiler...
Starting HTTP server...
Expected results

mod.py should be executed 2 times.

$ vprof -c cm "main.py"
Running MemoryProfiler...
I'm mod
Running FlameGraphProfiler...
I'm mod
Starting HTTP server...
Version and platform

vprof 0.37.4 python 3.6.2 Mac OSX

ahuigo avatar Feb 03 '18 16:02 ahuigo

It happens since profiling agents are run one after another: memory profiler always runs first and in the same process and others do run in their own processes for isolation. These processes are forked after memory profiler imports the code and child processes inherit that and that's why code is not reimported.

nvdv avatar Feb 05 '18 09:02 nvdv