Friday, August 18, 2006

Monitoring tools for Sun Java SE 6

Here is a good article flying over tools that are usefull to monitor JVM 1.6 :

http://java.sun.com/developer/technicalArticles/J2SE/monitoring/

Friday, August 11, 2006

Monitoring the GC on JVM 1.4

As JConsole is provided with Java 1.5, Marco sent me a link to open source software that monitors the GC, using the jvm "verbosegc" option.

http://www.tagtraum.com/gcviewer.html

Understanding the garbage collector

Here is a good article (in french) by Romain Guy explaining how the Sun's JVM garbage collector works and how it is possible to set the GC mode

http://gfx.developpez.com/tutoriel/java/gc/

Thursday, August 10, 2006

Memory dumps are usefull

Here is a JVM option very interesting :
-XX:+HeapDumpOnOutOfMemoryError usefull to identify memory leak responsability

Sun's JVM options : the (big) list

I just put this link (thanks to Marco) :

http://blogs.sun.com/roller/resources/watt/jvm-options-list.html

I 'll make no comment about the difficulty to tune a virtual machine. Oh.. I would said just a few words : prefer design and don't hope you will tune your quick development that has been quickly deployed in production under preasure.

Inside the Sun's JVM memory

Yesterday, my manager asked me about a problem concerning the eden space memory. So, this is a summary of JVM's memory management.

Heap Size
The allocation of memory for the JVM is specified using -X options when starting ColdFusion

JVM option Meaning
-Xms initial java heap size
-Xmx maximum java heap size
-Xmn the size of the heap for the young generation

(extended options)
-XX:MaxPermSize maximum permanent generation size (for creating object instances)

For efficient garbage collection, the -Xmn value should be lower than the -Xmx value.

Heap size does not determine the amount of memory your process uses
If you monitor your java process with an OS tool like top or taskmanager, you may see the amount of memory you use exceed the amount you have specified for -Xmx. -Xmx limits the java heap size, java will allocate memory for other things, including a stack for each thread. It is not unusual for the total memory consumption of the VM to exceed the value of -Xmx.

Garbage collection
There are essentially two GC threads running. One is a very lightweight thread which does "little" collections primarily on the Eden (a.k.a. Young) generation of the heap. The other is the Full GC thread which traverses the entire heap when there is not enough memory left to allocate space for objects which get promoted from the Eden to the older generation(s).
If there is a memory leak or inadequate heap allocated, eventually the older generation will start to run out of room causing the Full GC thread to run (nearly) continuously. Since this process "stops the world", ColdFusion won't be able to respond to requests and they'll start to back up.
The amount allocated for the Eden generation is the value specified with -Xmn. The amount allocated for the older generation is the value of -Xmx minus the -Xmn. Generally, you don't want the Eden to be too big or it will take too long for the GC to look through it for space that can be reclaimed.

Stack size
Each thread in the VM get's a stack. The stack size will limit the number of threads that you can have, too big of a stack size and you will run out of memory as each thread is allocated more memory than it needs.
JVM option Meaning
-Xss the stack size for each thread
-Xss determines the size of the stack: -Xss1024k. If the stack space is too small, eventually you will see an exception class java.lang.StackOverflowError .

Wednesday, August 09, 2006

How to monitor your application

I just found an article about how to use the JConsole that is included in Java SE 1.5. The article also presents in a few words the JMX phylosophy.

http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html

SwingWeb 1.0 : a new swing to web bridge framework

Wooh! It's a great day. There's a new framework that allows to publish a swing application on the web. I just put the link here but I will write another message about it. This is really great.

http://swingweb.sourceforge.net/swingweb/

Tuesday, August 08, 2006

Batch processing in Hibernate

I read this article that is very interesting (thank you very much Marco) :

Suppose you need to insert 200,000 records into a database in Hibernate. You'll need to adjust the following settings:

//set the JDBC batch size (it is fine somewhere between 20-50)
hibernate.jdbc.batch_size 30

//disable second-lavel cache
hibernate.cache.use_second_level_cache false

//and now do your job like this
Session S=SF.openSession(); //SF = SessionFactory object
Transaction T=S.beginTransaction();

for (int i=0;i<200000;i++)
{
record r=new record(...);
S.save(record);
if(i % 30==0)
{ //30, same as the JDBC batch size
//flush a batch and release memory
session.flush();
session.clear();
}
}

//clean
T.commit();
S.close();
(Author : Anghel Leonard)

Monday, August 07, 2006

Debugging application servers

Today, I found a great article that explain how to debug remotly several application servers.

Follow this link

Java Look And Feel : a simple article

As I love simple articles, I found one interesting about how to male a Java Look And Feel. I think It's time for me to learn somthing different that rewriting the paint() method.

Link to the article


First Step

Humm... Well it's done! I don't want to spam Marco's blog (javacomptoir) anymore with dailly messages. On this blog, I will write about my readings, about articles I found on the web. In many cases, I will be about Java. But sometimes, It will be about related technologies such as databases, global software architecture and... my favorite activity during spare times : Violet, THE Very Intuitive Object modeling software that I develop behind Cay S. Horstmann.

Thus, this blog will be a sort of bookmark with some experience feedbacks