I was reading the documentation when I came in doubt with the following phrase:
Since the collector supplements the reference counting already used in Python, you can disable the collector if you are sure your program does not create reference cycles.
What does this mean? If I disable the garbage collector (gc.disable()) and I do something like this:
a = 'hi'
a = 'hello'
will 'hi' remain in memory? Do I need to free the memory by myself?
What I understood from that sentence is that the gc is an extra tool made up expecially to catch reference cycles and if it is disabled the memory is still automatically cleaned using the reference counters of the objects but the reference cycles will not be managed. Is that right?
'hi'will indeed remain in memory, but attempting to free it would be wrong. Being a string literal it'll be interned and stored as a constant (in the code object). But that probably wasn't your question. I suggest you choose a more innocent example (something involving lists perhaps) to divert attention from that issue. - user395760awas referenced to something more complex, instead a simple string literal, will that 'something' remain in memory? Can't I do something to free the space in memory? - zer0unoa = [1]; a = something else. - user395760