1

I am trying to understand how memory_profiler works in python especially in the context of for loops. In particular, as you can see the increment column here shows negative usage, which I cannot understand.

Can anyone explain the memory profile of this snippet?

The following snapshot shows a memory profile of a python code snippet:

   290 602.2148437500 MiB -53838.4804687500 MiB           for fname in self.foo.bar:
   291 602.2148437500 MiB -53460.6132812500 MiB               if fname.endswith('html'):
   292 602.7109375000 MiB -9612.6601562500 MiB                   soup = BeautifulSoup(self.foo.bar_dict[fname],'html.parser')
   294 602.7187500000 MiB -9629.5312500000 MiB                   self._process_links(soup, fname)
2
  • Could you mention your operating sytem? This looks like a bug to me Commented Apr 5, 2018 at 15:48
  • it's a Mac OS Sierra Commented Apr 5, 2018 at 16:44

1 Answer 1

1

The output on loops is the maximum of the times that line was executed. The second line should show the diff with respect to the previous line, but this is obviously wrong in this case.

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.