views:

462

answers:

4
+2  A: 

Another obvious way is to use any Java library that leaks memory. (e.g. Qt Jambi)

About lambdas, read here and here and here. I think this is fixed in the latest versions of Clojure.

Brian Carper
+2  A: 

There is the intern call as well.

Note that your examples are not leaking memory in the common sense of the word. You can still access the objects (not sure about the classes -- I assume one can re-find them via some API), i.e. they haven't been lost. With certain things like the classes and interned strings it is just impossible to forget the data so the effect is the same.

HD
If its allocated and should not be I tend to call it leaked. Could you help me understand how to loose memory with the intern call?
Arthur Ulfeldt
A: 

Clojure memory leaks will usually be very similar to Java memory leaks. However the fact that collections are "persistent" means that if you add something into a collection and don't realize that you retained a reference to the old version of the collection as well as the new value means that memory is consumed to keep the old version hanging around.

David Plumpton
+2  A: 

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!

cgrand