Why I Don't Use The JVM
yakkstr.com
yakkstr.com
Java can't do this because Java self-modifies code (JIT) to run faster while it's running. Once all your classes are loaded into ram though, the memory gets consumed at a much more leisurely pace. However, multiple apps can't reuse each other's already mapped into memory code like they can with PHP, etc. As far as appserver restarts, just pay the money for JRebel already and quit complaining. Your life will be so much better.
Some interesting stuff here http://wikis.sun.com/display/HotSpotInternals/PerformanceTec...
A better comparison would be a real world app that scales to a number of users - tell me about JVM memory usage and performance then.
The abstraction breaker here is that your application often has a set of ideal GC settings, which need to be set. You cannot forget about the garbage collector when using the JVM.
People worry about scaling too much in general, IMO, but you'll actually get more mileage out of your hardware with something Clojure or Scala than you will with Python/PHP/Ruby/Perl.
Also, we need to consider the alternative. Where would we go if we didn’t have the JVM? It’s not like .Net is much better in this regard. We could go without a system as heavyweight as these two but then we lose all the advantages that come along with that weight.
Certainly, those advantages are not needed for a lot of purposes. Looking at what he’s running I would say he probably doesn’t need the weight of the JVM.
That said, I’m pretty sure I couldn’t do my current project anywhere but the JVM (well, okay, they’re all Turing machines so technically I can, but bear with me). I’ll gladly fork over the cash for a beefier VPS if it that’s the cost of the JVM.
Full disclosure: I am considered a Scala evangelist.
Response: Learn to manually configure its memory useage, don't just go with the default.
Not really front-page worthy.
I ran web apps that serviced 10x more users off of a 512 meg VPS with SBCL :-|
Anybody up for a sword-fight? jousting?
Do some testing to see how much memory you have allocated to the JVM - how much resources each of your rails apps are consuming.. Use a Heap Analyser (or similar) - it could give you good insights into what is hogging up the resources.
I do agree though with the goodness of reducing memory use and I like to check memory use and execution speed when I look at comparative benchmarks like Computer Language Benchmarks Game.
I mentioned specifically what I was doing, and how much RAM it took.
public static void main(String[] args) throws Exception { Thread.sleep(10000); System.out.println("hello world"); }
Heap - 5M, Used heap - below 2M. All defaults.
(the "sleep" is there to have time to connect Java VisualVM)
Edit: This ia a real rails app, so it's a bit of a tangent from my post, but I'm looking at it right now. I spun it up with trinidad, dev mode, and requested the home page. It used over 600MB. It's an admittedly heavy homepage, asset wise, but it will run out of heap if I set the max heap any lower than 500MB.
Edit 2: let me try it with MRI
Edit 3: MRI took about 225MB, about half the memory. In this case JRuby is clearly better because we run it in threadsafe mode.
I'd figure when dealing with that kind of memory constraint the only real contenders would be things like C, FORTH, or maybe PICAXE BASIC.
You can allocate as much or as little memory as your application needs. I run many personal web projects on a JVM sitting on top of a free-tier AWS EC2 micro-instance. I have tomcat6 instances running with <32MB footprint.
Perhaps you need to better understand what you're putting on the JVM and why it needs what it does
I think the commenter you're quoting is confusing the heap size with the total size. Or I'm missing something and would love for someone to show me what I'm missing.
http://wiki.eclipse.org/Jetty/Tutorial/Jetty_HelloWorld
Java ecosystem is too big, and it is common for newcomers to overlook the juicy parts. The mainstream frameworks and libraries reflect the mainstream use of java: big apps for medium/big companies.
You may wanna try playing with some variables. With the following command line:
java -cp .:servlet-api-2.5.jar:jetty-all-7.0.2.v20100331.jar -client -XX:MaxPermSize=1M -Xmx2M -Xms2M HelloWorld
I've added -client -XX:MaxPermSize=1M -Xmx2M -Xms2M. It took it down to 7Mb from 9Mb. However, this should not concern you in VPS/Amazon EC2 instances, as you can always run linux there, and these problems should not come by.$ java -cp .:servlet-api-2.5.jar:jetty-all-7.0.2.v20100331.jar -client -XX:MaxPermSize=1M -Xmx2M -Xms2M HelloWorld Error occurred during initialization of VM Too small initial heap for new size specified
I can't get it to run in under 30MB RES according to top. This is after hitting it with a little traffic, i'm not sure if you hit yours with any traffic.
Note that depending on the enverionment it may say it is too small, so you may have to ramp up a bit some of these stats. I also get it if I set lower than then ones I gave.
Note that jvm is very tunnable[1,2]. Also note that you can use a 32 bit jdk in a 64bit machine. It won't get you beyond 2GB vm, but if you are going for small memory, this is not something that matters (and it should allow you to get to a very small memory footprint).
Also note that there are other JVMs, like Oracle's JRockit (with extra memory options[3]), and KVM[4] (designed for small memory footprint[5]).
But hey, that is lower than 32 MB already!
Edit
You can also try some other lesser drastic measures[6,7]. Note that you are getting in less mainstream use of the JVM, and things can get a little crazy in this area.
[1] http://www.oracle.com/technetwork/java/javase/tech/vmoptions...
[2] http://www.caucho.com/resin-3.0/performance/jvm-tuning.xtp
[3] http://download.oracle.com/docs/cd/E15289_01/doc.40/e15060/t...
[4] http://en.wikipedia.org/wiki/K_virtual_machine
[5] http://java.sun.com/products/cldc/wp/
[6] http://www.coderanch.com/t/202896/Performance/java/Ways-redu...
[7] http://stackoverflow.com/questions/4893192/process-memory-vs...
If that's not good enough go ahead and write the whole thing using C. You can get one hell of a small "Hello, World!" program using C.