Quote:
|
Whilst Python discards memory instantly, your OS usually does not. If a chunk of memory is freed by a program, and you have plenty of free RAM around, then the OS will often keep the chunk of memory around until it's needed.
|
True, but so is the converse. If you, or another application, need more memory than is available, the OS will swap a page of memory to disk until that memory is required again. The memory swapped out will be chosen using an algorithm such as "least recently used" or "least frequently used". While the approach isn't perfect (thrashing can occur under certain conditions), it is likely to be more effective than off-the-cuff steps.