RSS feed [root] /weblog /java




login:

password:

title search:




 


Wed Jul 20 00:30:24 HKT 2011

java



(google search) (amazon search)
second
download zip of files only

Fri Feb 03 00:10:48 HKT 2012 From /weblog/java/performance

various tips



Interestingly, PrintWriter, if pooled, shows considerable performance improvement. The creation of the object is expensive because of a call to get the line separator in its constructor.

http://sachinhejip.blogspot.com[..]/08/experiences-in-java-performance.html

Experience in twitter - http://www.umbrant.com/blog/2012/twitter_jvm_tuning.html

(google search) (amazon search)


Thu Feb 02 23:43:14 HKT 2012 From /weblog/java/features

debugging


VisualVM , a collection of tools for debugging and monitoring - http://www.infoq.com/news/2008/05/visualvm

Presentation of BTrace, which allow user to have event base tracing - https://btrace.dev.java.net[..]ts/8510/98299/BTrace_BOF-5552_J12008.pdf

JDK command line tools which help to solving memory issue - http://plumbr.eu/blog/solving-outofmemoryerror-jdk-tools

(google search) (amazon search)


Sun Jan 15 20:08:42 HKT 2012 From /weblog/java/features

jmx


Support of JMX from common java library - http://www.javacodegeeks.com[..]ling-jmx-in-hibernate-ehcache-qurtz.html

sample code show how to get vm info at jmx - http://blogs.sun.com/jmxetc/entry/how_to_retrieve_remote_jvm

An excellent short tutorial of JMX - http://java.sun.com/developer/technicalArticles/J2SE/jmx.html

Monitoring all tomcat 5 JMX information, with free tools and java startup config - http://jroller.com[..]illiams/20050202#monitoring_tomcat_5_5_x

Task manager like jconsole plugin - http://blog.luminis.nl[..]is/entry/top_threads_plugin_for_jconsole

Performance cost of JMX - http://weblogs.java.net[..]nus/archive/2006/07/how_much_does_i.html

Monitoring Local and Remote Applications Using JMX 1.2 and JConsole - http://onjava.com/lpt/a/5226

(google search) (amazon search)


Thu Dec 29 22:02:25 HKT 2011 From /weblog/java/performance

leak


List some common causes of memory leak in application restart. - http://www.patrickpeak.com[..]/Weblog/your_web_app_is_leaking#comments http://blog.dynatrace.com[..]/20/the-top-java-memory-problems-part-1/

Incorrect use of threadlocal - http://www.szegedi.org/articles/memleak.html

Memory leak if load JDBC class incorrectly - http://www.szegedi.org/articles/memleak2.html

Serialization and ResourceBundle issue from core library (fixed) - http://www.szegedi.org/articles/memleak3.html

PermHeap bloat in and only in server VM - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4957990

String.subString() still held a big big char[] - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4513622

One pitfall of URLClassLoader, it cause leak from classloader, which is not obvious from the code - http://www.zeroturnaround.com/blog/rjc201/

(google search) (amazon search)


Wed Dec 28 23:28:19 HKT 2011 From /weblog/java/fundamental

time


Java timezone ID reference - http://david.uebelacker.ch[..]etrive-locale-and-timezone-from-request/ http://tutorials.jenkov.com[..]m/java-date-time/java-util-timezone.html

setTimeZone affects calls to set(), but doesn’t change the existing Calendar time? So if we wanted to change the time zone we are working with, we have to adjust all the time fields too…but a SimpleDateFormatter still would show it as the current time zone. - http://keyholesoftware.wordpress.com[..]1/joda-time-the-future-of-java-datetime/

(google search) (amazon search)


Sun Nov 13 02:37:44 HKT 2011 From /weblog/java/concurrency

Join


Example of Join - http://cnapagoda.blogspot.com/2010/01/thread-join-method.html

(google search) (amazon search)


Sat Nov 12 10:22:50 HKT 2011 From /weblog/java/features

tools


Trouble shooting guide, introduct few tools help to check issues - http://java.sun.com/j2se/1.5/pdf/jdk50_ts_guide.pdf

(google search) (amazon search)


Sun Oct 30 02:36:47 HKT 2011 From /weblog/java/hacks

cracking java


"hi there".equals("cheers !") == true
This is because in the JDK 1.3 SUN is caching the hash code so if it once is calculated, it doesn't get recalculated, so if the value field changes, the hashcode stays the same.

http://www.artima.com/forums/flat.jsp?forum=106&thread=4864

How to Modifying an Application without Modifying Its Source Code, with {-Xbootclasspath/p:} - http://www.ddj.com[..]M4OQSNDLPCKH0CJUNN2JVN?_requestid=186396

Override string! - http://www.javacodegeeks.com/2011/10/weird-funny-java.html

(google search) (amazon search)


Sun Oct 30 02:36:23 HKT 2011 From /weblog/java/fundamental

static


Loading and unloading static fields, unlocd the class - http://www.javacodegeeks.com[..]0/java-secret-loading-and-unloading.html

(google search) (amazon search)


Wed Oct 19 20:23:53 HKT 2011 From /weblog/java/features

reflection


Good : dynamic, generic
Bad: slow, don't work with Obfuscators and most searching and refactoring tools

http://jroller.com/page/ie?entry=time_to_reconsider_reflection

A very nice tool to get parameter name - http://paranamer.codehaus.org/ (e.g.: user of getUser(User user))

How to improve the performance - http://coding-masters.blogspot.com[..]-reflection-as-fast-as-direct-calls.html

The problem of using reflection to modify final field - http://www.azulsystems.com[..]7-writing-to-final-fields-via-reflection

(google search) (amazon search)


Sun Oct 16 23:31:45 HKT 2011 From /weblog/java/concurrency

Phasers


Similar to Barrier - http://tech.puredanger.com/2008/07/08/java7-phasers/

An example, show how to coordinate producer and consumer with Phaser - http://javaforu.blogspot.com[..]08/java-7s-jucphaser-short-tutorial.html

(google search) (amazon search)


Tue Oct 04 00:23:34 HKT 2011 From /weblog/java/fundamental

garbage


Some overview articles - http://javarevisited.blogspot.com[..]/2011/04/garbage-collection-in-java.html http://jeremymanson.blogspot.com[..]10/01/garbage-collection-references.html http://www.oracle.com[..]work/java/javase/gc-tuning-6-140523.html

Interview with Azul, about the pauseless GC - http://www.infoq.com/interviews/gil-tene-azul-zing

A story of how to tune GC - http://kirk.blog-city.com/why_do_i_have_this_long_gc_pause.htm

NewRatio ( XX:MaxNewSize ) is important, but usually ignored - http://blogs.oracle.com[..]ector/entry/the_second_most_important_gc

Java memory configuration and monitoring - http://blog.codecentric.de[..]ry-configuration-and-monitoring-3rd-act/

How Garbage Collection differs in the three big JVMs - http://blog.dynatrace.com[..]ollection-differs-in-the-three-big-jvms/

Garbage Collection Bootcamp 1.0 - http://www.lucidimagination.com[..]1/03/27/garbage-collection-bootcamp-1-0/

(google search) (amazon search)


Tue Oct 04 00:14:14 HKT 2011 From /weblog/java/libraries

ehcache


Cache by size - http://scaleaholic.blogspot.com[..]easy-java-performance-tuning-manage.html

(google search) (amazon search)


Sat Oct 01 14:25:08 HKT 2011 From /weblog/java/performance

profiler


Introduction to jmap, visualvm and btrace - http://www.infoq.com/articles/java-profiling-with-open-source

JMP http://www.khelekore.org/jmp/ is an easy to setup and provide real time data choice. However it will crash JVM occasionally. So may be the one using web interface is better for us: http://oss.metaparadigm.com/jmemprof/

Articles -
Onjava - http://www.onjava.com/lpt/a/6689
Eclipsecolorer profiler, however that plugin require you install binary yourself, somehow tedious if you move from one machine to another machine - http://www.theserverside.com[..]tss?l=EclipseProfiler&asrc=EM_NLN_476666

A total java version of profiler!!: http://jiprof.sourceforge.net

Few other profiler haven't get time to try:
Free:
http://jcoverage.sourceforge.net/
http://www.tagtraum.com/gcviewer.html
http://profiler4j.sourceforge.net/
http://www.jamonapi.com

Eclipse plugin:
http://jmechanic.sourceforge.net/
http://eclipsecolorer.sourceforge.net/index_profiler.html
http://www.eclipse.org/mat/

Need $$:
http://www.quest.com/jprobe/
http://www.javix.com/home/analyzer.html
http://www.ej-technologies.com/products/jprofiler/overview.html

See if the information useful.

(google search) (amazon search)


Sun Sep 25 09:35:12 HKT 2011 From /weblog/java/concurrency

yield


Yield is not that reliable- http://www.azulsystems.com[..]-pair-of-somebody-elses-concurrency-bugs

(google search) (amazon search)


Sat Sep 24 00:19:47 HKT 2011 From /weblog/java/concurrency

tutorial


Another nice tutorial set of concurrency framework - http://www.javacodegeeks.com/search/label/Concurrency

Java concurrency, Building and testing concurrent applications for the Java platform - http://www.ibm.com[..]g/kp/j-kp-concurrency/index.html?ca=drs-

(google search) (amazon search)


Mon Sep 19 00:41:52 HKT 2011 From /weblog/java/features

realtime


Develop with real-time Java, Create applications with predictable response times - http://www.ibm.com[..]/training/kp/j-kp-rtj/index.html?ca=drs-

(google search) (amazon search)


Sun Aug 28 19:58:48 HKT 2011 From /weblog/java/concurrency

monitoring


Sample code of try-sync


import sun.misc.*;

import java.lang.reflect.*;

public class MonitorUtils {
private static Unsafe unsafe = getUnsafe();

public static boolean trySynchronize(Object monitor) {
return unsafe.tryMonitorEnter(monitor);
}

public static void unsynchronize(Object monitor) {
unsafe.monitorExit(monitor);
}

private static Unsafe getUnsafe() {
try {
for (Field field : Unsafe.class.getDeclaredFields()) {
if (Modifier.isStatic(field.getModifiers())) {
if (field.getType() == Unsafe.class) {
field.setAccessible(true);
return (Unsafe) field.get(null);
}
}
}
throw new IllegalStateException("Unsafe field not found");
} catch (Exception e) {
throw new IllegalStateException(
"Could not initialize unsafe", e);
}
}
}


http://www.javaspecialists.eu/archive/Issue194.html

(google search) (amazon search)


Wed Aug 24 00:55:53 HKT 2011 From /weblog/java/libraries

Code Inspection


Comparison of difference static code analysis - http://weblogs.java.net[..]rar/archive/2006/11/talking_about_s.html

and http://www.javacodegeeks.com[..]-tools-source-code-optimization-and.html

(google search) (amazon search)


Mon Aug 15 23:40:53 HKT 2011 From /weblog/java/performance

usage


Offline parsing heap dump, good for analysis huge heap dump at server with GTK - http://www.eclipse.org[..]index.php?t=rview&goto=703990#msg_703990

Nice explanation of GC - http://redstack.wordpress.com[..]sualising-garbage-collection-in-the-jvm/

Get call back for memory allocation, should be very useful - http://blogs.lessthandot.com[..]s/applying-kanban-to-it-processes-part-2

Detailed discussion of analysis memory consumption in Java - http://kohlerm.blogspot.com[..]mory-consumption-of-netbeans-versus.html

it probably one of the nicest feature of java 5 - dump VM for you to analyst http://blogs.sun.com[..]apdumponoutofmemoryerror_option_in_5_0u7

This article present a simple, and possible not accurate method to track object creation and finalization. May be not that useful in general but sometime is convenience - http://www.devx.com/tips/Tip/30833?trk=DXRSS_JAVA

checking memory consumption at object level - http://www.jroller.org[..]im?entry=again_about_determining_size_of

Sun contain a nice library for we to investigate heap stat - http://elliotth.blogspot.com[..]om/2005/01/java-equivalent-of-heap1.html

Use java.util.Observable to Monitor Object State changes - http://www.devx.com/tips/Tip/22592?trk=DXRSS_JAVA

(google search) (amazon search)


Mon Jul 25 22:32:16 HKT 2011 From /weblog/java/performance

option list


Full VM option list : http://blogs.sun.com/roller/resources/watt/jvm-options-list.html, update for Java7 - http://nerds-central.blogspot.com[..]ot.com/2011/07/all-jvm-7-xx-options.html

HotSpot JVM garbage collection options cheat sheet - http://aragozin.blogspot.com[..]spot-jvm-garbage-collection-options.html http://www.oracle.com[..]va/javase/tech/vmoptions-jsp-140102.html

An example and story about effect of difference VM parameter affecting the performance - http://www.javaspecialists.eu/archive/Issue191.html

Complete list of -XX options from Sun JVM 6 - http://www.md.pp.ru/~eu/jdk6options.html

Discussion about -XX:MinHeapFreeRatio parameter - http://www.gossamer-threads.com[..]s.com/lists/lucene/java-user/44286#44286

The other detailed guide for VM parameters tuning - http://java.sun.com/j2se/1.5/pdf/jdk50_ts_guide.pdf

Here is a more simple cookbook - http://java.sun.com/performance/reference/whitepapers/tuning.html

A outdated (1.4) , compehensive but still not really too detailed, overview of various GC tuning - http://www.petefreitag.com/articles/gctuning/

Some say following VM parameter is good enough
-server -Xmx -XX:+UseParallelGC
http://blogs.sun.com[..]/page/binublog?entry=java_tuning_for_xml

Some say is useful if you have huge memory
-XX:+UseLargePages
http://blogs.sun.com[..]dagastine?entry=java_se_tuning_tip_large

Some say below parameter keep GC in low pause
-XX:MaxGCPauseMillis=5000
Some say below parameter are very optimal
-XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:NewSize=1200m -XX:SurvivorRatio=16
http://www.theserverside.com[..]d.tss?thread_id=41258&ASRC=EM_NNL_347804
Some say those parameter is good
-XX:+UseConcMarkSweepGC
-XX:ParallelCMSThreads=1
-XX:+CMSIncrementalMode
-XX:+CMSIncrementalPacing
-XX:CMSIncrementalDutyCycleMin=0
-XX:CMSIncrementalDutyCycle=10
http://blog.mikiobraun.de/2010/08/cassandra-gc-tuning.html

Just in case anyone is curious, the flags enabled by -XX:+AggressiveOpts in JDK 1.6.0_25 are:

-XX:+EliminateAutoBox
-XX:AutoBoxCacheMax=20000
-XX:BiasedLockingStartupDelay=500
-XX:+DoEscapeAnalysis
-XX:+OptimizeStringConcat
-XX:+OptimizeFill

(google search) (amazon search)


Wed Jul 20 00:20:33 HKT 2011 From /weblog/java/fundamental

collections


Detailed decision of arraylist and linkedlist, consist of a lot benchmark results, take a look if interested: http://javachaos.crazyredpanda.com/?p=99

One bug from java HashMap explaining it can be difficult to achieve fail-fast - http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6625725 http://java.dzone.com/articles/do-your-iterators-always-fail

Performance difference of difference collection - http://java-persistence-performance.blogspot.com[..]0/12/what-is-faster-jvm-performance.html http://leolewis.website.org[..]/2011/07/14/java-collection-performance/

A treelist implementation - http://binkley.blogspot.com/2007_02_01_archive.html

Implement LRU cache using LinkedHashMap - http://vanillajava.blogspot.com[..]11/06/java-secret-lru-cache-in-java.html

Problem of using soft-reference for automate cache clean up - http://comments.gmane.org[..]gmane.comp.java.jsr.166-concurrency/7982

(google search) (amazon search)


Mon Jun 27 00:27:08 HKT 2011 From /weblog/java/concurrency

hint


A nice list of hints about concurrency in java - http://www.weiqigao.com[..]c_burke_java_concurrency_by_example.html

Testing about java parallel processing - http://embarcaderos.net[..]ng-and-multi-core-utilization-with-java/

Some concurrency basic information - http://blog.andrewhubbs.com/?p=107

Tutorial of concurrency package - http://tutorials.jenkov.com/java-util-concurrent/index.html

Using Latch with Executor - http://binkley.blogspot.com[..]06/new-shimmer-for-java-concurrency.html

(google search) (amazon search)


Fri Jun 17 19:16:36 HKT 2011 From /weblog/java/concurrency

collections


Even though

private List synchList = Collections.synchronizedList(new LinkedList());

is thread safe, serialize sync List is NOT thread safe for sure. The story is, if you only synchronized the collection, and if we try to get the iterator in concurrent access environment, it will throws currencymodificationexception . I personally think this is a bug of having Collections.synchronizedCollection().

For collection is small, may be making defensive copy http://www.javapractices.com/Topic15.cjp is good. Otherwise, in java5, there is concurrency collection.

reference:
http://jroller.com[..]ntry=collections_synchronizedlist_broken
http://jroller.com/page/ctarrington?entry=java_collections_trivia

Map operation, include use of FutureTask and putIfAbsent() method from ConcurrentMap. - http://www.javaspecialists.co.za/archive/newsletter.do?issue=125

Other then lterate through the elements, adding and removing elements can also be problem, this article document a few good cases about that - http://rayfd.wordpress.com[..]en-a-synchronized-class-isnt-threadsafe/

Samples of using Queue.drainTo() - http://binkley.blogspot.com[..]rforming-fixed-amounts-of-work-with.html

http://tech.puredanger.com/2009/02/28/java-7-transferqueue/

Overview of blockingqueue - http://tutorials.jenkov.com[..]/java-util-concurrent/blockingqueue.html

Simple benchmark - http://java-persistence-performance.blogspot.com[..]jvm-performance-part-iii-concurrent.html

Multi-thread behaviour - http://vanillajava.blogspot.com[..]hread-safety-issues-with-vector-and.html

(google search) (amazon search)


Sat Jun 11 09:59:18 HKT 2011 From /weblog/java/concurrency

volatile


Examples of how to use volatile - http://www.ibm.com/developerworks/java/library/j-jtp06197.html

Related with volatile, explanation of thread safe of initalize with final / non-final variable - http://www.nabble.com[..]On%09DemandHolder-Idiom---tf4384557.html

http://jeremymanson.blogspot.com[..]07/08/volatile-does-not-mean-atomic.html
http://jeremymanson.blogspot.com[..]com/2009/06/volatile-arrays-in-java.html

Difference between volatile and synchronization - http://stackoverflow.com[..]7/volatile-keyword-in-java-clarification http://javarevisited.blogspot.com[..]atile-keyword-java-example-tutorial.html

(google search) (amazon search)