Is Google search getting socialized?

I ran some search on Google and there they are telling me someone in my social circle has the answer for me. They have the disclaimer it’s a BETA feature. But, I wasn’t aware this is existing.

So, What else is coming Google? Telling me who my real friends & foes are…:)

How to crash a JVM easily?

The intent of this article is to crash a JVM either “gracefully” or “non-gracefully”. It does not only mean JVM dying due to fatal errors.

If you can make it, then you should know how to break it. I think its more applicable to software systems than anything else. Being Java developers, we occasionally see JVM crashing either because we do something really silly or probably due to system’s limitation(bug, memory, threads etc.). But I was wondering, if I want to crash a JVM deliberately, what is the easiest way? In other words, with less line of code.

How “easy” is to crash a JVM? I am not talking about killing the process from Task Manager or running kill command in Unix :) .

Here are some of the options I came up with. If anyone can think of more “creative” ways, feel free to share it on the comments.

1.) JVM crash due to StackOverflow.

	public class JVMCrashTest {
		public static void main(String[] args) {
			main(args);
		}
	}
  

Exception in thread “main” java.lang.StackOverflowError

2.) This one will fail due to memory not being enough. We can use the same technique with data types other than Integer.

	public class JVMCrashTest {
		public static void main(String[] args) {
			Integer integers[] = new Integer[Integer.MAX_VALUE];
		}
	}
	

Exception in thread “main” java.lang.OutOfMemoryError: Requested array size exceeds VM limit

3.) This technique is very similar to the second one. Again, this approach can be tried with other data structures also.

	import java.util.*;
	public class JVMCrashTest {
		public static void main(String[] args) {
			ArrayList list = new ArrayList();
			for (int i = 0; i < Integer.MAX_VALUE; i++) {
				list.add(new Object());
			}
		}
	}
	

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

We constructively crashed the JVM, so now what?. Let's talk little bit about these approaches. Option 1 is very simple(less code) and my most favorite. It got into my thinking little more than how JVM can be crashed, possibly hinting some limitations which I never thought of before. But, I am going to save that discussion for a separate topic of its own.

Option 2 & 3 are very similar which may be fixed by adding more memory. In the meanwhile, if anyone can add more to this list, it will be great.

Note: The above code was run using JDK 1.6.0_18's JVM with the default memory settings.

Good bye Mephisto, Hello WordPress!

Mephisto has been my blogging/CMS platform for almost 3 years. Overall I was satisfied with it until recently when my hosting company started doing Ruby & RoR upgrades. Since Mephisto is not supported by anybody at this time and I’ve had a hard time getting it to work with the latest Ruby & RoR versions, I thought its a good time to look for alternatives. So, the first choice came to mind was WordPress.

I should admit WordPress installation was a breeze and I am quite impressed with its UI & overall design. Needless to say, it has whole bunch of themes & plugins if you want to do more with it. In my opinion, RoR doesn’t seem to be a stable or robust platform compared to PHP based frameworks.