{"action":"opened","issue":{"url":"https://api.github.com/repos/pythonprofilers/memory_profiler/issues/219","repository_url":"https://api.github.com/repos/pythonprofilers/memory_profiler","labels_url":"https://api.github.com/repos/pythonprofilers/memory_profiler/issues/219/labels{/name}","comments_url":"https://api.github.com/repos/pythonprofilers/memory_profiler/issues/219/comments","events_url":"https://api.github.com/repos/pythonprofilers/memory_profiler/issues/219/events","html_url":"https://github.com/pythonprofilers/memory_profiler/issues/219","id":389131284,"node_id":"MDU6SXNzdWUzODkxMzEyODQ=","number":219,"title":"large negative increment in %mprun on ipython","user":{"login":"nekketsuuu","id":4374702,"node_id":"MDQ6VXNlcjQzNzQ3MDI=","avatar_url":"https://avatars3.githubusercontent.com/u/4374702?v=4","gravatar_id":"","url":"https://api.github.com/users/nekketsuuu","html_url":"https://github.com/nekketsuuu","followers_url":"https://api.github.com/users/nekketsuuu/followers","following_url":"https://api.github.com/users/nekketsuuu/following{/other_user}","gists_url":"https://api.github.com/users/nekketsuuu/gists{/gist_id}","starred_url":"https://api.github.com/users/nekketsuuu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nekketsuuu/subscriptions","organizations_url":"https://api.github.com/users/nekketsuuu/orgs","repos_url":"https://api.github.com/users/nekketsuuu/repos","events_url":"https://api.github.com/users/nekketsuuu/events{/privacy}","received_events_url":"https://api.github.com/users/nekketsuuu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-10T04:17:26Z","updated_at":"2018-12-10T04:17:26Z","closed_at":null,"author_association":"NONE","body":"## Problem\r\n\r\nThe `%mprun` line profiler reported an unexpected big negative increment values in a for loop. I came across this problem when running it on Google Colaboratory, and also [another user](https://ja.stackoverflow.com/q/51078/19110) said the same problem occurred on IPython on macOS.\r\n\r\nI used most recent version of HEAD of `master` branch (memory_profiler 0.54.0 + PR #202 + something) by `pip install -U https://github.com/pythonprofilers/memory_profiler/archive/master.zip`, but the problem was reproduced.\r\n\r\n## Code\r\n\r\nThe original source code is from <https://jakevdp.github.io/PythonDataScienceHandbook/01.07-timing-and-profiling.html>.\r\n\r\n```python\r\n!pip install -U https://github.com/pythonprofilers/memory_profiler/archive/master.zip\r\n%load_ext memory_profiler\r\n```\r\n\r\n```python\r\n%%file mprun_demo.py\r\ndef sum_of_lists(N):\r\n    total = 0\r\n    for i in range(5):\r\n        L = [j ^ (j >> i) for j in range(N)]\r\n        total += sum(L)\r\n        del L # remove reference to L\r\n    return total\r\n```\r\n\r\n```python\r\nfrom mprun_demo import sum_of_lists\r\n%mprun -f sum_of_lists sum_of_lists(1000000)\r\n```\r\n\r\nSee the actual notebook [here](https://colab.research.google.com/drive/10kEGosg2hkfnI58S_b1fOCIynampwkG1). You can try and re-run the above example.\r\n\r\n## Result\r\n\r\n```\r\nFilename: /content/mprun_demo.py\r\n\r\nLine #    Mem usage    Increment   Line Contents\r\n================================================\r\n     1    150.3 MiB    150.3 MiB   def sum_of_lists(N):\r\n     2    150.3 MiB      0.0 MiB       total = 0\r\n     3    150.3 MiB      0.0 MiB       for i in range(5):\r\n     4    181.1 MiB -46807065.7 MiB           L = [j ^ (j >> i) for j in range(N)]\r\n     5    181.1 MiB      0.0 MiB           total += sum(L)\r\n     6    150.3 MiB   -123.0 MiB           del L # remove reference to L\r\n     7    150.3 MiB      0.0 MiB       return total\r\n```\r\n\r\n## Environment\r\n\r\n* IPython on Google Colaboratory\r\n* memory_profiler 0.54.0 + 4 commits (959d9fc10f210c90f77dea80e8a42d39a291c613)\r\n\r\n## Related?\r\n\r\n#9, #195, #211\r\n\r\nAlso the same problem is reported on Stack Overflow: [\"Strange increment value reported during IPython memory profiling\"](https://stackoverflow.com/q/47490896/5989200).\r\n"}}
{"actor":{"display_login":"nekketsuuu"}}