Saved Bookmarks
| 1. |
Discuss the strategies employed by python for memory allocation? |
|
Answer» Python uses two strategies for memory allocation- Reference counting and Automatic garbage collection: Reference Counting: works by counting the number of times an object is referenced by other objects in the system. When an object's reference count reaches zero, Python collects it automatically. Automatic Garbage Collection: Python schedules garbage collection based upon a threshold of object allocations and object de-allocations. When the number of allocations minus the number of deallocations are greater than the threshold number, the garbage collector is run and the unused block of memory is reclaimed. |
|