On July 26, 2013 at 10:39:47 AM, Jürgen Hötzel (juer...@hoetzel.info) wrote: I did some memory profiling on a Clojure Application.
I wondered why 361000 clojure.lang.Symbols exist. So I did some object browsing on the memory dump and found duplicate symbols. After checking the source: static public Symbol intern(String nsname){ int i = nsname.indexOf('/'); if(i == -1 || nsname.equals("/")) return new Symbol(null, nsname.intern()); else return new Symbol(nsname.substring(0, i).intern(), nsname.substring(i + 1).intern()); } I realized that interning of a symbol always returns a "new" Symbol object. If a symbol X is interned twice, shouldn't the second Symbol.intern(X) return the previous interned symbol object? It's not the symbol that's being interned, it's the string that represents the symbol. If you look at the equals() method for Symbol, you'll notice that it is using object equality (the double equals operator, ==) to compare the name of the symbol. So, if you have two symbols with the same name, they will be equivalent because they have the same string object internally. However, since each symbol can have its own metadata, the symbol objects cannot be interned as your are describing. Keywords fill that role, as Marshall mentioned. -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com 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 clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.