SLIME: trouble with java.lang.OutOfMemoryError

13 views
Skip to first unread message

Paul Mooser

unread,
Jan 8, 2009, 4:46:34 PM1/8/09
to Clojure
I was playing around earlier while following Mark Engelberg's blog
post, and I found that to my surprise, when I exhaust the heap
(java.lang.OutOfMemoryError), it basically fails to pop up the window
that gives me the exception (where you can normally abort or throw the
cause), and the REPL itself only shows "; Evaluation aborted" and is
non-responsive (sometimes it will show the exception in the REPL
itself).

In order to resolve this, I've tried the following steps:

- update swank-clojure to latest
- update SLIME to latest
- update clojure itself to latest

None of these help.

Other exceptions I've deliberately caused, such as an NPE, work as
expected with SLIME. Can anyone else reproduce this behavior ? In the
past, specifically when playing with filter, I have exhausted the heap
many times with clojure, and SLIME has always worked perfectly - I'm
not sure when this behavior was introduced but I haven't been able to
track down exactly when it started happening.

Paul Mooser

unread,
Jan 10, 2009, 3:03:42 PM1/10/09
to Clojure
After talking to Jeffrey Chu, it seems like what is actually happening
is possibly fairly obvious (in retrospect) - the java process runs out
of heap space, and there's not even enough memory to keep swank-
clojure working properly. Jeffrey tried some examples with just a
plain REPL (without SLIME), and managed to get a dead REPL after
causing an out of memory error, so there may be more fundamental lower
level things going on, and it's not clear that this can really be
addressed on the SLIME side.

I'm not sure what a good solution to this problem would be, but I
thought I'd post an update for anyone who was curious what the actual
issue was.

Christian Vest Hansen

unread,
Jan 10, 2009, 3:20:03 PM1/10/09
to clo...@googlegroups.com
I don't think it is possible to define a way to deal with heap
saturation that is general enough to cover all programs written in
Clojure, and therefor I don't think this is something that the Clojure
runtime should deal with at all.

Personally, I only know of two ways to handle OutOfMemoryErrors: 1)
let the program blow up and hope someone notices or 2) look at your
body, pick the limb you are least likely to be needing pretty soon and
cut it off (aka. free some memory) and _then_ yell for help through
some hopefully reliable channel.
--
Venlig hilsen / Kind regards,
Christian Vest Hansen.

e

unread,
Jan 10, 2009, 3:35:11 PM1/10/09
to Clojure
i wondered about this when I was asking about eclipse analogies. The
vm that runs a program that you are writing should have nothing to do
with the vm your editor is using. Maybe there should be some way for
the actual running program to be in one VM, and then the REPL
communicates to it via RMI. I know Rich talks about a new model for
distributed concurrency ... seems like the whole program should
optionally run in such a distributed (interprocess) thread. RMI, xml
rpc, jms. Then one thing running out of memory has nothing to do with
the other.

on another aside that is mostly a rant ... totally ignorable, and not
directly on topic:
Nobody ever dings clojure, and I can't because I don't know it. I'm
excited to (attempt to) learn it despite the fact that one major thing
I was looking for in a new language is one that starts it's design
thinking about the IDE . . . .actually building an IDE and letting the
language follow in test-driven manner. Zero configuration. J
somewhat seems like that, though I don't know if it started like that,
but there isn't any syntax highlighting. Like, I don't really program
in Java. I program in Eclipse . . . which assists me in writing
java. Maybe I just think an IDE should have a GUI builder, project
manager, version control, reviewing and markup (collaboration), wiki,
milestone calendar, doc-builder that ties code to the docs, debugging,
packaging, obfuscating, etc. You download language x. You run the
launcher for language x. An IDE pops up. As you code, the IDE has
some sort of "build" or "deliver" button, nevermind the REPL part that
is useful during development ... that makes something you can give to
a user. That sort of thing is what makes a language accessible to the
masses. Is there a discussion group of project underway to make a
dedicated IDE or Eclipse plugin for clojure? And ..... it's asking a
lot to ask the next generation to make emacs their friend. It seems
like that's what I'll need to do for now with clojure, right? And I
wont have dot completion, I'm thinking even for java stuff (the main
place I see dots). I guess what I am saying is that I actually pick
the language based on the editor. I pick java over c# because I enjoy
Eclipse way more than every time I've had to try to use visual studio
(although that seems to finally be getting a little better). Maybe we
at least need a jEdit plugin for clojure.

Luc Prefontaine

unread,
Jan 10, 2009, 4:28:21 PM1/10/09
to clo...@googlegroups.com
Try this:

http://github.com/djspiewak/jedit-modes/tree/master/clojure.xml

I work with Eclipse on a daily basis because of the java code base I have to deal with but it was
asking my computer to carry an elephant until... I got my hands on a quad-core with 6 Gig of RAM
and I had loaded in RAM at boot time all the tools I use regularly.

Eclipse is useful to java because of all the bureaucratic configuration you need to create a Java app with
almost every framework (I use Spring). You need wizards to create stuff, heavy validation tools to keep your code and
XML configurations in sych, an integrated Java debugger, ...

I started to work with Clojure in fall and used Scite after adding a Clojure mode to it by cloning the lisp mode
and making mods to it. Later I tried Vim and JEdit also.

I started using Emacs 3 weeks ago just to refresh my memory (I was using Emacs in the mid-80s).

I do not use SLIME, just a separate REPL and I reload code when I update a file or just cut & paste in the terminal window.
Whether you use Emacs or another language sensitive editor does not make a huge difference.
SLIME is a nice add-on but it may be confusing and there still a couple of issues to fix about the SLIME Clojure mode.
I tried it but tossed it away for a couple of months by necessity, I will come back to it when it will have matured a bit.

I do not see any need for Eclipse to code in Clojure since the amount of code written compare to Java is
much more smaller. Eclipse for Clojure is like using a dead blow mallet to hang a picture.

A light language sensitive editor is what you need to track all these parenthesis :)))
For debugging I am happy with JSWat but I do not need it very often.
The core of the learning curve is to understand the functional language concepts and how Clojure implements
these concepts plus the ones specific to Clojure, not the syntax.

I walked this learning curve while coding in Clojure for a system that will be in production next Monday and all of that without
Eclipse... I am old, my brains have burned a lot of cells along the way and I am not as fast as I used
to be when I started programming :))) so if I can do it, I expect that others can do so...

For me Eclipse is like getting a wheeled walker, that's the step just before my own death, I use it when
there's not other choice than crawling inch by inch :))))

Luc

Paul Mooser

unread,
Jan 10, 2009, 5:00:42 PM1/10/09
to Clojure
Yeah, I'm not really sure how I think the problem would be ideally
solved. It would just be nice for an interactive programming
environment to be able to recover from all exceptions that happen at a
higher level than the VM itself.

On Jan 10, 12:20 pm, "Christian Vest Hansen" <karmazi...@gmail.com>
wrote:

e

unread,
Jan 10, 2009, 5:10:22 PM1/10/09
to Clojure
thanks for the encouragement.

As for eclipse, I just don't get the same feeling. I love the cntl-
space and cntl-\ things that stub out your code (not just for dot
completion). . . complete with cells for variables that repeat in the
template (yeah they probably took this from emacs, but I can add more
templates using a GUI or an xml file . . . .dirt simple). Awesome.
I mean, people talk about how easy python is, right? For an OO
person, python should be nice and gentle. Well, until I got PyDev for
eclipse I wasn't into it at all. NOW (and only now), it's awesome.
It's an awesome language BECAUSE there's an eclipse plugin for it.
When I forget what something is, I hold down cntl, which turns it into
a hyperlink, I click on it, and it follows me to the definition. Who
cares where that is. I hit the back button and I'm back where I was.

There's a big difference for me between an IDE and an editor. I cant
remember. Besides J, was it clean that comes with it's own IDE?
http://clean.cs.ru.nl/About_Clean/body_the_clean_ide/body_the_clean_ide.htm
. . . . swi-prolog has a page talking about IDE's, but seem to have
the same problem of pointing folks a bunch of directions to try a
bunch of things that may or may not work . . . and vary from system to
system . . .and may or may not come with GUI-based version control
clients.

Thanks for the information on jEdit, too.
I'll check it out and Netbeans (enclojure?), too, though I'd hate to
have to install the monstrosity that is Netbeans just to work with
clojure. Oh, I get it! Yeah, if clojure is your only language, then
eclipse could be seen as insane. But no, because, no doubt you'll
want source control and other team development tools and the stuff I
mentioned above. Yeah, it needs a lot of memory . . . because it's
doing a lot of stuff. A lot of stuff I want. It underlines things
orange that might not be safe, marks them red if they are just plain
wrong . . . even tells you when you have spelling errors in your
comments. How is that not cool? Maybe Netbeans does that stuff, too,
so if you're using it for everything then, ok.

I think it's useful (but correct me if I'm just being negative) to
capture some of these impressions. I know I'll have a tough incline
convincing my coworkers to make this our next language. If I fail due
to the IDE issue it may be interesting to know that I may end up
visiting F# on the dark side. It actually has some concurrency built
in (transparently, I think?), and, I'm sure will come with an IDE.
Then again, it won't be free (another I'm hoping this is couched as
feedback and not as complaint. It's great to see progress in
languages).


On Jan 10, 4:28 pm, Luc Prefontaine <lprefonta...@softaddicts.ca>
wrote:

e

unread,
Jan 10, 2009, 5:15:04 PM1/10/09
to Clojure
exactly. . . .but I bet a lot of people would just reply that this is
not possible to address since the REPL is the one and only vm.
Disclaimer, I'm only guessing at that, too. I don't understand any of
this, yet. But if that's the case, fix that. Have the REPL send
messages to the vm that's running the program . . . instead of the
REPL being the program.

Paul Mooser

unread,
Jan 10, 2009, 5:31:47 PM1/10/09
to Clojure
If I'm not mistaken, this is fairly close to how SLIME works, when
connected to a remote VM. The remote VM is running some server code
which allows it to communicate with SLIME, which is running inside of
emacs.

e

unread,
Jan 10, 2009, 9:18:11 PM1/10/09
to Clojure
seems like enclosjure addresses a bunch of my problems/questions. It
also seems to work like we wanted SLIME to work, more or
less . . .where you attach to the vm that's used for execution . . .
only you attach to the REPL, I think, which still accomplishes the
goal of keeping the editor separate from the memory, but what about
having the REPL being able to attach to the vm it is managing. Then
it wouldn't be something that NetBeans/enclosure is doing . . . rather
something that's part of the language.

So, yeah. enslojure sets up a HelloWorld that you can play with right
away. In fact, when you click on "build" it even tells you how you
could run your application from the command line using a java
command. It jars up you whole clojure project and everything. Nice.
On the other hand, I couldn't figure out how to use NetBeans' run
button. it couldn't find main or something. So I also couldn't debug
using NetBeans' debugger because of this. Also, it isn't clear how to
get different clojure files to work together. Do you use the (load)
function? If so, I don't know how the project thinks of relative file
locations. It's not as clean/clear as java (for a beginner, at least)
where you just import classes you want to use . . and make
packages. . . . or modules in python. I don't know what the notion of
"path" is in clojure. I see the namespace stuff but have no clue how
to make it work yet. Are you just supposed to use one giant file for
all your work? That wouldn't be good for teams, for sure. . . only
for hacking. Also the REPL errors are USELESS to a beginner.
something about iSeq all the time. The moral for me there was no to
make an error. Better than where I was before enclojure. Again, I
contend that a language is only as good as the IDE that has been
written for it, which is why it's cool to see enclojure coming along
(even though it means learning NetBeans instead of Eclipse).

lpetit

unread,
Jan 11, 2009, 9:14:59 AM1/11/09
to Clojure
Hello,

If you like eclipse and would like to see where clojuredev (eclipse
plugin) is right now, you can give a quick look at the current state
of clojuredev by trying to immediately install it via the update site
link :

http://clojure-dev.googlecode.com/svn/updatesite/

Still not ready for public availability (it's alpha alpha), but that's
a start.

And you could subscribe to clojuredev user ml: very very low traffic
(no message right now :-), and we could jut publish announces when
something interesting for users is ready on the update site.

Quickly, what is available right now :
- enable a java project with clojure dev nature (contextual menu of
the java project, -> Clojure submenu)
- wizard for creation of clojure project (= java project + clojure
nature)
- syntax coloring
- some keyboard accelerators for :
- jump to matching bracket : Ctr+Shift+P
- Go to start of top level defun : Ctrl+Alt+A (or AltGr+A)
- Go to end of top level defun : Ctrl+Alt+E (or AltrGr+E)
- Select (highlight) top level defun : Ctrl+Altr+H (or AltrGr+H)
- Launch configuration for clojure : enable to select which files to
load on startup, and other things similar to java launch
configuration. Not yet possible to select a main method other than
clojure.lang.Repl (will change at some point in time)

If you have time, please give it a try, do some feedback, and fill
free to submit tickets if you find bugs (in the features listed above,
the other ones you may find via menus are not yet ready, even if the
menu are there).

Regards,

--
Laurent

e

unread,
Jan 11, 2009, 10:39:39 AM1/11/09
to Clojure
great. will do.

Korny Sietsma

unread,
Jan 11, 2009, 10:28:51 PM1/11/09
to clo...@googlegroups.com
I have had similar problems with enclojure. But having gone through
similar IDE pain working in Ruby on Rails, the Netbeans support ended
up being way ahead of most IDEs, so I have hopes that enclojure will
get there in time. (My biggest annoyance? The fact that you can't
open existing code as a new project - I want to browse
clojure-contrib, but I can only do it by creating a new "hello world"
project first!)

I'd kind-of like to re-learn emacs - many years ago I was a keen emacs
user - my biggest problem is that I'm on a Mac, and I have to keep
switching between IDEs and PCs (my work desktop is Linux) not to
mention languages. I don't have the spare brain cells to learn
another set of key bindings! I need an IDE with easy built-in help,
and while "M-x slime-cheatsheet" is handy, it doesn't spare me the
world-o-pain when I hit "Alt-w" (one of the few keystrokes my fingers
remember from last time) and my emacs window closes! Argh!

So I try to stick with IDEs that have everything on menus, so when I
forget the "open file anywhere in project" command for a particular
IDE, I can look it up. (Does Emacs have this, by the way? It doesn't
really have a "project" concept... )

I might look at the JEdit plugin though - JEdit is nice, for simple
editing, which might be good enough for me for now.

Incidentally, if you want a language with an editor built in, why not
look at Smalltalk? I vaguely recall that was a big part of the
original language concept. I haven't ever played with it myself, but
the most popular current flavour seems to be Squeak:
http://www.squeak.org/

- Korny
--
Kornelis Sietsma korny at my surname dot com
kornys at gmail dot com on google chat -- kornys on skype
"Every jumbled pile of person has a thinking part
that wonders what the part that isn't thinking
isn't thinking of"

Eric Lavigne

unread,
Jan 11, 2009, 11:34:39 PM1/11/09
to clo...@googlegroups.com

Incidentally, if you want a language with an editor built in, why not
look at Smalltalk?  I vaguely recall that was a big part of the
original language concept.  I haven't ever played with it myself, but
the most popular current flavour seems to be Squeak:
http://www.squeak.org/

Smalltalk is an excellent language (though I have a personal preference for Lisp). It also provides a glimpse into what the term "object-oriented" originally meant. In case anyone reading this thread decides to explore Smalltalk, here are a few pointers to introductory information.

Yes, Squeak is popular, mostly because it is very portable, easy to install, and open source. It is also developed primarily as an introductory programming environment for children, and that has held it back as an environment for professional programmers.

Pharo is a recent fork of Squeak, with the intention of completely ignoring the needs of children and focusing on making a good environment for professional programmers.

http://code.google.com/p/pharo/

Also, there is a very nice web development framework for Smalltalk. Smalltalk is worth learning just for a chance to see a new way of doing web development.

http://seaside.st/

I would recommend starting with Squeak as it is very easy to work with (if children can handle it, so can you), and switch to Pharo later when you are ready for production deployment. The following book is a good starting point for either environment (and is available for free online).

http://squeakbyexample.org/

Adrian Cuthbertson

unread,
Jan 12, 2009, 12:03:56 AM1/12/09
to clo...@googlegroups.com
>I might look at the JEdit plugin though - JEdit is nice, for simple
>editing, which might be good enough for me for now.

I similarly haven't had time to relearn emacs and have used jedit quite
sucessfully with jedit-mode. I keep one or more terminal window tabs open
each with a REPL launched with rlwrap and then just copy and paste from the
associated jedit tab/buffer. With up_arrow and dn_arrow bound to
"back_history" and "forward_history" in rlwrap, it's easy to try stuf in the
REPL, recall/edit previous lines, etc, and copy/paste back to jedit when
necessary. The main advantage for me is this works identically when I have
an ssh session open to a server with REPL/rlwrap. I can similarly copy/paste
from jedit and do very interactive development directly on the server as
well as on my local machine, switching between everything with one or two
keystrokes. I'm just about down to a pure keystroke driven dev environment
with almost never touching the mouse. Primiive and a bit messy, but it works
well.

[Footnote to the above - I also have a terminal tab open just for compiles.
Using ant (build.xml's adapted from clojure's build), the full cycle
includes then tabbing to the ant terminal, recalling/running the build and
using rsync to copy changed classes to the server. I can then immediately
switch to the server/ssh tab and reload/work with the newly built code.]
Reply all
Reply to author
Forward
0 new messages