+ 13

How memory is managed in python??

5th Jan 2018, 1:34 PM
Abhivarshini Maddala
Abhivarshini Maddala - avatar
2 Answers
+ 13
https://docs.python.org/3/c-api/memory.html
5th Jan 2018, 2:17 PM
Md. Nafis Ul Haque Shifat
Md. Nafis Ul Haque Shifat - avatar
+ 2
So in python garbage collection is done automatically compared to C++ where we must write code to remove unwanted memory. It works on reference counting, the number of times a variable has been referred to. For example when a new variable is created, its reference count increases by 1 and when we mutate it, its reference increases again. If we delete or change reference, its reference count decreases. Python memory collection is handled very systamatically. Hope this helps ^_^.
9th Jan 2018, 3:45 AM
Athleteboy
Athleteboy - avatar