Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 17011

Memory leakage in python?

$
0
0

I have python scripts that calls a function foo that performs some operations that uses say 10GB of memory and returns the small object res to the main program. After printing res I delete the res, but top shows the ipython process is sill using about 1GB of memory. How can I ensure the process frees up all unused memory?

def foo():   .... # some complication operation   return resif __name__ == "__main__":    res = foo()    print(res)     del res

I tried using gc.collect() but the it does not change anything.I have read that sometimes the memory becomes fragmented and python can not reclaim all the memory.


Viewing all articles
Browse latest Browse all 17011

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>