Out of memory... ouch

* This page is related to "Deploying Clojure websites".

I've written before about how I'm running four Clojure-driven websites out of a single JVM on my VPS. No problems for many months, but today I tried to make a blog post and got all kinds of out-of-memory errors. Hopefully I didn't lose any / many user comments on this blog in the past couple days, but it's possible.

I restarted the JVM and gave it a bit more RAM to play with, I imagine this will fix things. But we'll see. It occurs to me now that there may be such a thing as too much caching.

6 Comments

http://gravatar.com/avatar/4d84ec3981443dfd9c287e845b60d2ce.jpg?d=identicon
Brian says:

Hello Brian, I'm testing the comment system. Sincerely, Brian.

Jan 20, 2010 12:12 PM PST
http://gravatar.com/avatar/89b5f2822ca5e5d7a796e1382000cf6b.jpg?d=identicon
Andres F. says:

Too much caching? Blasphemy.

Au contraire, you probably just need more of it!

Jan 20, 2010 03:39 PM PST
http://gravatar.com/avatar/849dd1f1ccdb800f9fb925f65db18117.jpg?d=identicon
DC Jobs says:

Until I read this post, I didn't ever realize the potential effect of caching on memory. I guess the more features a site has, the more that can go wrong.

Jan 21, 2010 08:21 AM PST
http://gravatar.com/avatar/37e3da6f3d377350e98e3ee68654a042.jpg?d=identicon
Martin Jul says:

For caching, you will be fine if you just remember to use weak references so that the garbage collector can reclaim the memory of the cached items when memory is short.

I have seen the same problem frequently in systems where people just stuff things into an unbounded key-value hash with hard references that never releases infrequently used entries or gives up cached instances when memory pressure is high.

Jan 22, 2010 03:24 AM PST
http://gravatar.com/avatar/4aae8204cbda78ad2e13a335d2183285.jpg?d=identicon
Rick says:

Does your cache take advantage of Java's WeakReferences? That might be an out. You also may want to to try the JRockit JVM.

Anyway, you site looks clean. I really tried doing web development in Common Lisp and gave up due to the library madness (lots of libraries, but the current versions of each don't work together - and most are underdocumented at best). You stuff is almost inspiring me to give Clojure a whirl, even though I really am anti-Java these days.

Feb 26, 2010 07:22 PM PST
http://gravatar.com/avatar/4d84ec3981443dfd9c287e845b60d2ce.jpg?d=identicon
Brian says:

No weak references, just Clojure data structures. Probably not the best idea but it's gotten me by for over a year so far. I think I've had to restart the server maybe 4 times.

Yes, I did a site in CL too and it was not a lot of fun to get running or keep running. Java sucks, but Java libraries are good. Well-documented and complete and widely tested. The Java libs you need for web development are generally wrapped in Clojure by now anyways, e.g. Compojure which wraps Jetty, so you don't get your hands dirty.

Think of Java as the assembler language for Clojure. Not sure where I picked up that phrase, but it's a great analogy. No one likes Java, but it's there if you need it for speed.

Feb 26, 2010 07:44 PM PST

Speak Your Mind

This says COWS.

Preview

Commenting Help

Email / Avatar

  • Supply your email address and your Gravatar will be used.
  • I will never email you and your address won't be published.

No HTML allowed!

All HTML is auto-escaped. Use Markdown. Examples:

  • *emphasis* = emphasis
  • **strong** = strong
  • [link](http://foo.bar) = <a href="http://foo.bar">link</a>
  • `code in backticks` = code in backticks
  •     code indented 4 spaces =
    code indented four spaces
  • > Angle-brace quoted text =
    Angle-brace quoted text