Wednesday, 16 June 2010

About Java Run Out Perm. Space

Recently, I met a issue on "run out memory of perm. space." in Tomcat server.

What is the memory leak? The dynamically allocated memory has become unreachable.

1) C/C++ is prone to cause memory leak, because it has no auto garbage collection mechanism.
2) JAVA: unbounded memory use, but

There are two types of Memory in JVM: Heap and Permanent.
What Heap for? dynamatically generating instances.
What Permanent for? store the templates, i.e. Classes, but not dynamically used.

So run out the memory of this part, mostly because it has been used out of boundary of the space, at least I think so. So increasing permananent memory from the default of 64mb to 150 mb.

Add java option: -XX:MaxPermSize=150m

Stack memory: 
In addition: java vm also manage a stack for the handling local var. and function calls; each thread has its own stack, seen as a private memory. If there is no memory left for storing local var., then java will throw a stack overflow error.

Heap memory: 
Java  VM maintain a memory space for a common usage for all threads, where all objects are created there. no matter where these class having been instantiated. When heap runs out, then java throws  java.lang.OutOfMemoryError.

So there are 3 different kind of memory usage in java. heap perm. and stack.


Can Jackson Deserialize Java Time ZonedDateTime

Yes, but must include JSR310. Thus ZonedDateTime can be deserialized directly from JSON response to POJO field. <dependency> <g...