Tuesday, May 11, 2010

Increase JVM memory when using Swank Clojure

When I am developing with Emacs, Swank, and Clojure I almost always need more memory than you get by default with "java -client" so I edited ~/emacs.d/elpa/swank-clojure-1.1.0/swank-clojure.el on my laptop permanently overriding the amount of memory that swank-clojure gives the JVM by adding one line:
(defun swank-clojure-cmd ()
"Create the command to start clojure according to current settings."
(swank-clojure-check-install)
(if swank-clojure-binary
(if (listp swank-clojure-binary)
swank-clojure-binary
(list swank-clojure-binary))
(delete-if
'null
(append
(list swank-clojure-java-path)
swank-clojure-extra-vm-args
(list "-Xmx1024m") ;; MLW 5/11/2010
...

2 comments:

  1. I'm using Maven to my Clojure projects, and clojure-maven-plugin allows to specify Java options, that also could be applied to swank and repl... And it's much easier to maintain classpath, etc.
    P.S. I don't remember, does Leiningen supports similar option or not
    ReplyDelete
  2. I usually start clojure with M-x swank-clojure-project

    If I need more than the default 64MB this elisp line in *scratch*

    (custom-set-variables '(swank-clojure-extra-vm-args '("-server" "-Xmx128M")))

    and another M-x swank-clojure-project is enough to use the new settings.
    ReplyDelete

Note: Only a member of this blog may post a comment.