Python vs Java garbage collection?
John Roth
johnroth at ameritech.net
Sat Dec 21 16:44:43 EST 2002
"Robert Oschler" <Oschler at earthlink.net> wrote in message
news:rV4N9.5714$uV4.3242709 at news2.news.adelphia.net...
> This is a very unscientific observation I have here, in the sense that
I've
> done no formal research, but in my web and newsgroup perusals, I seem
to
> have come across quite a few mentions of problems with Java
applications in
> regards to untimely garbage collection and memory "hogging". Yet I
have
> come across very few of the same complaints with Python.
>
> Is there a fundamental structural reason for this or is it simply
anecdotal
> coincidence or due to the kind of apps written with either language.
I'm
> not knocking Java, it's a fine language and it's been put to good use
> although admittedly I'm biased towards Python.
The differences depend on the Java version you're using. Java
versions through 1.2 used a garbage collector that didn't collect
unreferenced objects until virtual memory filled up, which let it take
quite a while before an instance's cleanup actions might be executed.
More recent versions use a different stragegy that reportedly
has many fewer problems, however most of the Java runtimes
out there with browsers are quite old.
Python, on the other hand, uses a reference counting strategy.
That tends to release unused objects immediately the last
reference vanishes, however, it has problems with objects
that are linked in a cycle. The latest versions fix this (mostly,)
but it's still wise to break cycles manually to get the best
results.
Hope this explanation makes sense.
John Roth
>
> thx
>
>
>
More information about the Python-list
mailing list