Thursday, 20 November 2014

What does JVM flag CMSClassUnloadingEnabled actually do?

The standard Oracle/Sun VM look on the world is: Classes are forever. So once loaded, they stay in memory even if no one cares anymore. This usually is no problem since you don't have that many purely "setup" classes (= used once for setup and then never again). So even if they take up 1MB, who cares.
But lately, we have languages like Groovy, that define classes at runtime. Every time you run a script, one (or more) new classes are created and they stay in PermGen forever. If you're running a server, that means you have a memory leak.
If you enable CMSClassUnloadingEnabled the GC will sweep PermGen, too, and remove classes which are no longer used.

JVM option -Xss - What does it do exactly?

Each thread in a Java application has its own stack. The stack is used to hold return addresses, function/method call arguments, etc. So if a thread tends to process large structures via recursive algorithms, it may need a large stack for all those return addresses and such. With the Sun JVM, you can set that size via that parameter.

Friday, 7 June 2013

Difference b/w include directive and jsp:include tag

The jsp:include tag is handled at request time. For every request that comes in for the index.jsp URL, the content.jsp servlet will be run when the jsp:include tag is encountered. In principle, this could have been done at translation time; the chunk of HTML from the content.jsp file could have been dropped right into the index.jsp servlet. This would be much less powerful, however. By processing includes at request time, the contents of the included file can change independently of the main file.


<%@include file="contents.jsp" %>
 
 
This tag is called a directive because it directs the page compiler to take some action. In this case, when it sees the directive, the page compiler will embed the contents of the contents.jsp file directly into the servlet that it is building for index.jsp. Subsequently, if the contents.jsp file is edited, index.jsp will not change. Browsers will continue to get the old message until the page compiler is forced to rebuild the index.jsp servlet.


Note- that the include directive specifies what is to be included with file=, whereas the jsp:include tag specifies page=. This nicely encapsulates the differences between the two: The directive includes a file as it is building the servlet at request time, and the tag includes another page at request time.