6

I read that one could manually collect garbage using

gc.collect()

Now I'm wondering when it is useful to do so. I suppose it is to some extent general Python logic. Say I have a large loop and in each loop will use big matrices Z and rewrite them again and again. Is it useful to remove the matrices and collect garbage in the end, if I don't change the size of Z?

The general question Under which circumstances can one actually observe the impact of forced garbage collection, especially when doing lots of numerical computation within numpy?

Community
  • 1
  • 1
FooBar
  • 15,724
  • 19
  • 82
  • 171
  • 1
    This is nearly a duplicate of: http://stackoverflow.com/questions/23977904/how-to-implement-garbage-collection-in-numpy – Benjamin Dec 08 '15 at 02:25

1 Answers1

0

As you can see in the answers in the comment, the simplest way to release memory is del array and let the garbage collector do its job.

Ramon Crehuet
  • 3,679
  • 1
  • 22
  • 37