Since I was already doing calls to gc.collect by hand after releasing
all references, this is unlikely to have a difference over that. One
way I was thinking of [over]-doing it was to do some processing, save
the state, exit the process entirelly, resume where it left of, rince
and repeat.

Obviously this can't be done in production, but it's for an internal
tool I'm making and could be done this way as a last resort.


On Oct 18, 11:55 am, Ross Peoples <[email protected]> wrote:
> Not sure what effect it will have, but I believe the only way to really free
> memory in Python is to use something like this:
>
> rows = db(...).select(...)
> del rows
>
> This won't immediately free the memory, but might make it free faster than
> dereferencing it. Alternatively, you can call gc.collect() to force
> dereferenced objects to be freed, but this is generally bad practice. There
> are only a few cases where you should actually use this, and your *might* be
> one. So try del or gc.collect() and see if that helps any. Just keep in mind
> that Python (or any managed memory language) makes it very difficult to
> manage memory manually.

Reply via email to