How is memory managed in python?

Answer Posted / chaitanya

Memory management in Python involves a private heap containing all Python objects and data structures. Interpreter takes care of Python heap and that the programmer has no access to it.

The allocation of heap space for Python objects is done by Python memory manager. The core API of Python provides some tools for the programmer to code reliable and more robust program.

Python also has a build-in garbage collector which recycles all the unused memory. When an object is no longer referenced by the program, the heap space it occupies can be freed. The garbage collector determines objects which are no longer referenced by the sprogram frees the occupied memory and make it available to the heap space.

The gc module defines functions to enable /disable garbage collector:

gc.enable() -Enables automatic garbage collection.

gc.disable() - Disables automatic garbage collection.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which compiler is best for python?

452


How to change a string in list ?

473


As python is more suitable for the server-side application, it is very important to have threading implemented in your server code. How can you achieve that in python?

458


What are the 3 types of numbers in python?

406


What is instance method?

446






What do you know about iterator protocol?

484


How is python an interpreted language?

442


Is python better than bash?

414


How to set the figure title and axes labels font size in matplotlib?

471


Who developed python?

473


Are sets hashable python?

453


What do you understand by python package?

479


What will be the output of ['!!welcome!!']*2?

565


In python, how do copy a file?

396


Is python object-oriented? What is an object-oriented programming

440