Skip to main content

Posts

Showing posts from August, 2006

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 ColdFusionJVM 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.Garba…

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)

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