I presume Clojure has something similar to GC in Java. If so, how do the GC algorithms used by Java compare with those of Clojure? Immutability is a good thing in the recent languages
such as Clojure and Scala. Often I become concerned with how those languages manage Memory and GC.
How does the user response time compare between Java and Clojure?
I understand that Clojure doesn't have a different GC algorithm since it runs in JVM, like Scala, Groovy and others.
Is the JVM that you use that could have different GC algorithms (SAPJVM, JRockit, Apache Harmony, etc).
But seems that some constructs in Clojure, for example persistent collections, tend to be long living objects;
this objects survive the partial garbage collections and only be collected when full GC runs.
If so much work is left to the full GC then could lead to JVM freezing episodes.
The usual workaround to this scenario is enable concurrent GC with a drawback on JVM performance.
Clojure as a JVM language leverages the GC that it is already used by the Java programming language.
You can even use any profiler you have. Just launch the VisualVM tool that is included in the SDK and see how your Clojure program is running.
When it comes to good memory management, Clojure doesn't blindly copy thing. It does it in a more smart way.
For example (conj x y) will return a new collection, that it is true; but it shares the content of the the old one. This is really fast and efficient.