pythonprofilers / memory_profiler

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

Memory_profiler return error "object is not defined" in Jupyter notebook #275

Closed ThuyTien1 closed 4 years ago

ThuyTien1 commented 4 years ago

Currently, I'm trying to use memory_profiler in Jupiter notebook as the following code:

%load_ext memory_profiler

def test1(n):
    return n+1
def test2(n):
    i = test1(n)
    %memit i
    %memit test1(n)
test2(10)

And it return error "NameError: name 'i' is not defined"

Btw, I try again with %memit test1(10) inside function test2() and it works for %memit test1(10). Can you guys help me to find the right way to use memory_profiler in jupyter notebook.

Many thanks.

fabianp commented 4 years ago

that's not the right syntax for %memit, please see README for examples