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

How does lambda function differ from a normal function in python?

474


How to open a text file and display its contents?

493


What is a for loop in python?

420


Why do u want this job?

441


Is python faster than python2?

454






What is wrong with the code?

507


How is fail over mechanism works in python?

436


What is GIL? What does it do?Talk to me about the GIL. How does it impact concurrency in Python? What kinds of applications does it impact more than others?

485


How to install a package and import?

465


What is argument in a function?

471


How to convert a list into a string?

455


When would you use a break statement in a for loop?

457


Can you sort a string in python?

423


How will you merge two dictionaries in python?

472


How do you write code in python?

472