News for hackers. Stuff that matters.
Re:Tracking Down a Python Memory Leak by gravypod on Wednesday December 07, 2016 @05:31PM (#13126875)
> "But if we're strictly speaking about Python objects within pure Python code, then no, memory leaks are not possible - at least not in the traditional sense of the term. The reason is that Python has its own garbage collector (GC), so it should take care of cleaning up unused objects."

I have a hard time beliving this. Java can have memory leaks so why couldn't Python?

Re:Tracking Down a Python Memory Leak by zipfle on Wednesday December 07, 2016 @05:51PM (#13126992)
I think that the author is defining memory leaks as permanently out of scope but not deallocated memory. In that sense I don't know of anything in vanilla Python, or Java, that would qualify as a memory leak. In the more intuitive sense of a memory leak being any failure to make objects available to garbage collection, (such as by retaining references to them in an unexpected place) leading to unchecked increases in a program's memory footprint, memory leaks are possible in either language.
Re:Tracking Down a Python Memory Leak by bbernard on Wednesday December 07, 2016 @06:47PM (#13127279)
Check out this SO thread: http://stackoverflow.com/questions/2017381/is-it-possible-to....

There are indeed many interpretations of what a memory leak is in Python.

In C/C++, you can forget to free memory, thus causing memory leaks. For example, you may call malloc(), but forget to call free(). In Python or Java, you can't do that; you don't need to explicitly "free" objects, as there's a GC.

Sure, you could leave rogue Python or Java objects in memory, but in my mind this isn't a "leak" in the same sense as a leak in C/C++. The Python interpreter (which is written in C) or some C extension may themselves cause real leaks, though.

I'm the author of the post. Maybe my reasoning was not explained clearly enough.

Re:Tracking Down a Python Memory Leak by winstonewert on Wednesday December 07, 2016 @05:59PM (#13127027)
Different definitions of memory leak.

In the post's definition, a memory leak is memory you can no longer reach but is still allocated. That's eliminated by Java and Python.

Of course, you can still waste memory in Java or Python in a variety of ways. But that's a different definition of memory leak then the post is using.