This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-22
Channels
- # bangalore-clj (6)
- # beginners (110)
- # boot (49)
- # cider (13)
- # cljs-dev (35)
- # cljsrn (5)
- # clojure (145)
- # clojure-conj (3)
- # clojure-dev (60)
- # clojure-italy (2)
- # clojure-nl (3)
- # clojure-russia (3)
- # clojure-serbia (1)
- # clojure-spec (116)
- # clojure-uk (58)
- # clojurescript (235)
- # cursive (14)
- # datascript (7)
- # datomic (31)
- # dirac (144)
- # emacs (1)
- # events (1)
- # hoplon (12)
- # leiningen (11)
- # luminus (60)
- # lumo (19)
- # off-topic (18)
- # om (74)
- # onyx (5)
- # pedestal (13)
- # precept (3)
- # re-frame (3)
- # reagent (15)
- # remote-jobs (7)
- # ring-swagger (25)
- # rum (1)
- # untangled (53)
- # vim (3)
i think i remember this being discussed recently, but are clojurescript keywords immutable and allocated? The reason being can someone flood the environment with many keywords and eventually exhaust the storage of them?
i thought i remembered a discussion that both clojure and cljs intern keywords and you cannot unallocate them?
@dpsutton There is the aspect that they participate in :optimize-constants
: https://github.com/clojure/clojurescript/wiki/Compiler-Options#optimize-constants
But there would only be a bounded number of those. I suppose you are concerned with dynamically-created keywords.
someone asking if their framework pulls them out of query strings can someone be malicious
A dynamically-created keyword (created via cljs.core/keyword
) is just a deftype
instance.
I can’t see any other way of looking at it. (source keyword)
doesn’t seem to register them (there’s only about 20 lines of code there.)
Perhaps there is something interesting in Clojure, and thus identical?
vs. keyword-identical?
being needed in ClojureScript.
Yeah @dpsutton in Clojure you can see (source keyword)
using clojure.lang.Keyword/intern
https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Keyword.java#L32
Well, it is not a WeakHashMap
, so the ConcurrentHashMap
entries would at least stick around, even if the guts of the values are gc’d
hmmm
(defn emits-keyword [kw]
(let [ns (namespace kw)
name (name kw)]
(emits "new cljs.core.Keyword(")
(emit-constant ns)
(emits ",")
(emit-constant name)
(emits ",")
(emit-constant (if ns
(str ns "/" name)
name))
(emits ",")
(emit-constant (hash kw))
(emits ")")))
Right, if you fire up a REPL in :repl-verbose
mode you will see that :foo
gets emitted as
new cljs.core.Keyword(null,"foo","foo",(1268894036))
This loop is not causing memory to grow for me (empirical verification)
(loop [n 0]
(keyword (str "kw" n))
(recur (inc n)))