Skip to content
Discussion options

You must be logged in to vote

gc.collect() is run automatically when a request for RAM cannot be served, unless this mechanism is switched off. gc.collect() frees up memory blocks which are not in use anymore and tries to combine them with adjacent free areas, but is does not move used memory blocks. That may lead to the so-called memory fragmentation situation, that there are many free small areas in RAM, and a request for a large amount of RAM cannot be served, even if gc.mem_free() tells, that the total amount of free RAM is sufficient. calling gc.collect() frequently serves for two purposes:

  • trying to avoid memory fragmentation.
  • shortening the time an automatic tgc.collect() would need.

The deliberate call of gc…

Replies: 4 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@cve2022
Comment options

Answer selected by beetlegigg
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants