Heap size does not change after function call. #568
-
Changes I did to
Next commands:
But I do not see any deallocation of heap size. What is the reason? This is also shown as memory leak if I give |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 2 replies
-
I converted this issue into a Q&A discussion. Please do not open issues for general questions if you are not sure they are bugs. This helps us a lot maintaining the repo. Thanks for understanding 🙏 |
Beta Was this translation helpful? Give feedback.
-
This is happening because CPython doesn't release that memory at teardown because it's still on the freelists of the interpreter, if you force the memory to be allocated to be higher you will find that once you surpass the freelist limit that memory it's indeed released. |
Beta Was this translation helpful? Give feedback.
-
How do I ensure memray to show leaks correctly then ? |
Beta Was this translation helpful? Give feedback.
-
No, it's nothing so complicated as that...
When I perform the steps you've given, I do see the heap size drop: That circle shows the spot where You may be thrown off by the fact that |
Beta Was this translation helpful? Give feedback.
No, it's nothing so complicated as that...
When I perform the steps you've given, I do see the heap size drop:
That circle shows the spot where
fib1()
has returned (and its temporary list has been freed) butfib2()
has not yet built up a large cache. As the program continues running, the cache owned byfib2()
gets larger and larger, until eventually it's even larger than the temporary list that was created whilefib1()
ran. That point marks the program's heap high water mark. 2 seconds later the main script finish…