What\'s the difference between StackOverflowError and OutOfMemoryError and how to avoid them in application?
From Javadocs: Exceptional conditions associated with JVM Stacks:
1) if insufficient memory can be made available to create the initial JVM stack for a new thread, the JVM throws an OutOfMemoryError.
2) If the computation in a thread requires a larger JVM stack than is permitted, the JVM throws a StackOverflowError.
3) If JVM stack can be dynamically expanded, and expansion is attempted but insufficient memory can be made available to effect the expansion, the JVM throws an OutOfMemoryError.
Exceptional conditions associated with Heap:
1) If a computation requires more heap than can be made available by the automatic storage management system, the JVM throws an OutOfMemoryError.