@alex-miller thanks, that explained a lot. I did check the UseStringDeduplication feature and that's exactly what I was looking for.
Funny thing is that it can only be implemented because strings are *immutable *in Java :P thus it is cheaper to store a reference to it since it will never change. @Tassilo that's actually a rather interesting example. I always wondered about it but didn't bother to ask it until now. If you see your example, you can see that the JVM is actually recognizing the characters inside the vectors are the same and only allocating one for each occurrence. On the other hand, the vectors although being exactly the same are not being recognized by the JVM as so. Thus, two different allocations are done even though only one would suffice (given their immutability). That was precisely my point: If you could identify that something is an exact copy of something else, why not just point to the first thing? From Alex miller, answer I know now that this is true for strings and for primitive values present in the source code. But what about keywords? vectors, hash-maps, sets? Of course, complaining about allocating those in the source code is non-sense as it would need a huge amount of them to even start to matter. But if you create lots of them at runtime then it is probably worth to look at it. Say for example a web-server that receives json objects with 70% of its content being (predefined) configuration values. If you allocate new strings/vector/hash-map for every request that you get, then your memory rises quite quickly. On the other hand if you keep a sort of "pool of values" and replace the new values with references to the ones in the pool then the total memory consumed is less than before. >From my understanding of the description of "UseStringDeduplication" this is what's been done for Strings, but I guess NOT for any other object. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
