I'm happy to release the first version of clj-memory-meter <https://github.com/clojure-goes-fast/clj-memory-meter>. It's a thin wrapper around jamm <https://github.com/jbellis/jamm>which allows measuring how much space an arbitrary object occupies. clj-memory-meter is usable from the REPL, can be loaded on-demand, and doesn't require to launch JVM with special parameters.
Blog post with a little more detail and usage examples: http://clojure-goes-fast.com/blog/introspection-tool-object-memory-meter/ To start, using add [com.clojure-goes-fast/clj-memory-meter "0.1.0"], or run the following with clj: $ clj -Sdeps "{:deps {com.clojure-goes-fast/clj-memory-meter {:mvn/version \"0.1.0\"}}}" Clojure 1.9.0 ;; Nevermind the warning, it doesn't break the library. user=> (require '[clj-memory-meter.core :as mm]) objc[59881]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/bin/java (0x1089814c0) and /Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home/jre/lib/libinstrument.dylib (0x10d9dc4e0). One of the two will be used. Which one is undefined. nil user=> (mm/measure (vec (range 100000))) "2.8 MB" user=> (mm/measure (list 1 2 3 4 5) :debug true) root [clojure.lang.PersistentList] 320 bytes (40 bytes) | +--_first [java.lang.Long] 24 bytes (24 bytes) | +--_rest [clojure.lang.PersistentList] 256 bytes (40 bytes) | +--_first [java.lang.Long] 24 bytes (24 bytes) | +--_rest [clojure.lang.PersistentList] 192 bytes (40 bytes) | +--_first [java.lang.Long] 24 bytes (24 bytes) | +--_rest [clojure.lang.PersistentList] 128 bytes (40 bytes) | +--_first [java.lang.Long] 24 bytes (24 bytes) | +--_rest [clojure.lang.PersistentList] 64 bytes (40 bytes) | +--_first [java.lang.Long] 24 bytes (24 bytes) "320 B" I hope this library will be useful for you. Enjoy! -- 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/d/optout.