Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I leak memory in Clojure?

For a presentation at the Bay Area Clojure Meetup on Thursday I am compiling a list of ways to leak memory in Clojure.

So far I have:

  • hold onto the head of an infinite sequence
  • creating lots of generic classes by calling lambda in a loop (is this still a problem)
  • holding a reference to unused data
  • ...

What else?

like image 294
Arthur Ulfeldt Avatar asked Dec 05 '22 06:12

Arthur Ulfeldt


1 Answers

By keeping a reference to a seq on a large collection. eg:

(drop 999990 (vec (range 1000000))) 

returns a seq of ten elements that holds a reference to the whole vector!

like image 134
cgrand Avatar answered Jan 17 '23 06:01

cgrand