RSS feed [root] /weblog /java



title search:


Sun Dec 14 09:36:42 HKT 2014


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

Thu Aug 31 10:38:43 HKT 2017 From /weblog/java/tools


The jhsdb tool is described on its Oracle JDK 9 Documentation Early Access page, "You use the jhsdb tool to attach to a Java process or to launch a postmortem debugger to analyze the content of a core-dump from a crashed Java Virtual Machine (JVM)." The tool comes with several "modes" and several of these modes correspond in name and function with individual command-line tools available in previous JDK distributions. The jhsdb tool not only provides a single tool that encompasses functionality of multiple other tools, but it also provides a single, consistent approach to applying these different functions. For example, the jhsdb command-line syntax for getting help for each of the "modes" is identical.[..]UID-0345CAEB-71CE-4D71-97FE-AA53A4AB028E

(google search) (amazon search)

Sat Aug 26 14:11:22 HKT 2017 From /weblog/java/fundamental


Some overview articles -[..]/2011/04/garbage-collection-in-java.html[..]10/01/garbage-collection-references.html[..]work/java/javase/gc-tuning-6-140523.html

Interview with Azul, about the pauseless GC -

A story of how to tune GC -

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

Java memory configuration and monitoring -[..]ry-configuration-and-monitoring-3rd-act/

How Garbage Collection differs in the three big JVMs -[..]ollection-differs-in-the-three-big-jvms/

Garbage Collection Bootcamp 1.0 -[..]1/03/27/garbage-collection-bootcamp-1-0/[..]ollection-interview-question-answer.html

How CMS work -[..]thecollector/entry/hey_joe_phases_of_cms

Compare between difference VM -[..]IsTheFastestGarbageCollectorInJava8.html

GC handbook -

Check what GC you are using -[..]16/04/determining-garbage-collector.html

About G1 Java Garbage Collector -[..]G1-Java-Garbage-Collector.html&Itemid=29

Tools to visualize GC -

Visualizing difference algorithm -[..]sualizing-garbage-collection-algorithms/

safepoints -

(google search) (amazon search)

Tue Jun 20 13:06:05 HKT 2017 From /weblog/java/performance


A case showing java is faster than C++ -[..]mgroups#!topic/comp.lang.c++/7aNw3PzPvMI

Case show how to improve GC time spend on a java application -[..]11/java-vm-beware-of-younggen-space.html

A case study of solving thread contention -[..]fighting-thread-contention-in-your-code/[..]-of-java-application-performance-tuning/

Notes about measuring map performance -[..]ronicle-map-and-yahoo-cloud-service.html

High Performance Java - Binary instead of Objects - John Davies -

jemalloc, look like a really nice tool -[..]c-to-get-to-the-bottom-of-a-memory-leak/

story of finding why there is so many GC -[..]horough-jvm-thorough-analysis-ygc-part01

GC thread blocked by system call -

We always need benchmark -[..]2017/06/15/forward-vs-backward-loop.html

(google search) (amazon search)

Fri Jun 02 17:55:34 HKT 2017 From /weblog/java/libraries


Introducing LALR parser in java -

(google search) (amazon search)

Thu May 18 10:29:03 HKT 2017 From /weblog/java/concurrency


Another nice tutorial set of concurrency framework -

Java concurrency, Building and testing concurrent applications for the Java platform -[..]/training/kp/j-kp-concurrency/index.html

JVM concurrency: Java and Scala concurrency basics -[..]/java/library/j-jvmc1/index.html?ca=drs-[..]reading-interview-questions-answers.html

5 things you didn't know about ... Multithreaded Java programming -

(google search) (amazon search)

Thu May 18 10:28:15 HKT 2017 From /weblog/java/features


5 things you didn't know about ... Java Database Connectivity -

(google search) (amazon search)

Wed May 17 10:27:49 HKT 2017 From /weblog/java/tools


Java Flight Recorder, a tool to record all detail of how the API work for undo and replay and detail profiling -

Creating Custom JFR Events -

Java Mission Control -[..]-mission-control-52-is-finally-here.html

Support of JMX from common java library -[..]ling-jmx-in-hibernate-ehcache-qurtz.html

sample code show how to get vm info at jmx -

An excellent short tutorial of JMX -

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

Task manager like jconsole plugin -[..]is/entry/top_threads_plugin_for_jconsole

Performance cost of JMX -[..]nus/archive/2006/07/how_much_does_i.html

Monitoring Local and Remote Applications Using JMX 1.2 and JConsole -

Collections of tools -[..]/client-side-server-monitoring-with.html

remote conenction with ssh -[..]nitoring-remote-jvm-over-ssh-jmx-or-not/

IBM healthcare API -[..]rary/j-healthcareapi1/index.html?ca=drs-

JVM Statistics with jstat -[..]k/2017/05/jvm-statistics-with-jstat.html

(google search) (amazon search)

Sat May 06 14:13:47 HKT 2017 From /weblog/java/features


Introduction of Lambdas expression in Java - , an example show how lambdas help to clean up the duplication -[..]mplifying-readwritelock-with-java-8.html

Another article about Java8 change, where Lambdas is the highlight -

Nice tutorial -

Huge list of articles -

Use lambdas to replace for-loop -[..]creating-your-own-loop-structure-in.html

Overview for new Date/Time library -[..]om/2014/05/java-8-features-tutorial.html

Grouping and partitioning with stream -[..]/11/java-8-streams-api-grouping-and.html
In a nutshell, make sure to never override a default method in another interface -[..]va-8-default-methods-can-break-your.html

Convert SQL feature to stream -[..]and-their-equivalents-in-java-8-streams/

(google search) (amazon search)

Thu Mar 30 14:48:57 HKT 2017 From /weblog/java/performance


Will you get any performance improvement if you manage memory yourself? -[..]ne-is-faster-java-heap-or-native-memory/

More heap, GC will get slower -[..]ing-heap-size-beware-of-the-cobra-effect

Collection of tools to analysis GC activities -

Another presentation of performance hint for hotspot or memory -

Show how to enable and analyze the verbose:gc out data -[..]3/01/java-verbose-gc-tutorial-video.html

Discussion and comparison of difference GC at Java 1.7 -[..]7/java-garbage-collection-distilled.html . And here is the detail experiment among those difference GC, look like G1 is quite promising -[..]ng-and-benchmarking-java-7s-garbage.html

Memory is not allocate to single block, thus even you allocate enough memory in term of size, it may not enough to held individual object -

Introduction to metaspace -[..]optimising-memory-consumption-first.html

Some comments about System.gc() -[..]om/2015/12/why-i-dont-like-systemgc.html[..]ng-your-java-garbage-collection-overhead

Logging stop-the-world pauses in JVM -[..]log/logging-stop-the-world-pauses-in-jvm

Why we should put difference app in same VM -[..]0/generational-disparity-in-garbage.html

Atlassian GC tuning guide -[..]ollection-gc-tuning-guide-461504616.html

Using jemalloc to get to the bottom of a memory leak -[..]c-to-get-to-the-bottom-of-a-memory-leak/

Troubleshooting-Java-Memory-Issues -

(google search) (amazon search)

Mon Mar 27 10:38:42 HKT 2017 From /weblog/java/features


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

A very nice tool to get parameter name - (e.g.: user of getUser(User user))

How to improve the performance -[..]-reflection-as-fast-as-direct-calls.html

The problem of using reflection to modify final field -[..]7-writing-to-final-fields-via-reflection

Using reflection for using test -[..]f-hacking-enums-and-modifying-final.html

Sharing about using invokedynamic -[..]ticles/Invokedynamic-Javas-secret-weapon

(google search) (amazon search)

Sun Mar 26 00:09:52 HKT 2017 From /weblog/java/string


Introduction to a library which support faster regular expression processing:[..]ite/archive/2006/03/a_faster_java_r.html[..]-expression-library-benchmarks-2015.html

Regex helper -

java-regular-expressions-cheat-sheet -[..]abs/java-regular-expressions-cheat-sheet

(google search) (amazon search)

Fri Mar 10 17:49:16 HKT 2017 From /weblog/java/concurrency


putall can cause ConcurrentModifcationException -[..]ses/sun/management/

Note on writing CopyOnWrite wrapper -[..]

Sometime this is a bit difficult for Chinese to be a good programmer, recently some colleague and me discuss about the behaviour of this class and look like we have difficult understanding

A: ConcurrentHashMap support for locking as this is thread-safe
B: ConcurrentHashMap is thread safe for read but not for write because there is no lock, we still need to have external lock to keep it thread safe. By the way, I get ConcurrentModificationException from this before.
C: ConcurrentHashMap don't support for locking but they still thread safe for all operations, which is how "This class is fully interoperable with Hashtable in programs that rely on its thread safety but not on its synchronization details." mentioned.

Too good that we can actually take a look at the source code to see what going on nowadays rather than just guessing -[..]HashMap&sourceid=opera&ie=utf-8&oe=utf-8 By the way, this constructor is useful for a lot of concurrency access but actually not many developer notice about this -[..]rrentHashMap.html#ConcurrentHashMap(int, float, int)

Lazy initialization of map values -[..]

HashMap.get() can cause infinite loop -[..]5/07/hashmapget_can_cause_an_infini.html

Discussing the effect of initCapacity() of HashMap in Java -[..]ltimatebb.cgi?ubb=get_topic&f=1&t=021171

OpenJDK and HashMap …. Safely Teaching an Old Dog New (Off-Heap!) Tricks -

We can run search in ConcurrenctHashMap -

(google search) (amazon search)

Tue Feb 28 17:10:49 HKT 2017 From /weblog/java/fundamental


Overview of weak, soft and Phantom References
Second, PhantomReferences avoid a fundamental problem with finalization: finalize() methods can "resurrect" objects by creating new strong references to them. So what, you say? Well, the problem is that an object which overrides finalize() must now be determined to be garbage in at least two separate garbage collection cycles in order to be collected. When the first cycle determines that it is garbage, it becomes eligible for finalization. Because of the (slim, but unfortunately real) possibility that the object was "resurrected" during finalization, the garbage collector has to run again before the object can actually be removed. And because finalization might not have happened in a timely fashion, an arbitrary number of garbage collection cycles might have happened while the object was waiting for finalization. This can mean serious delays in actually cleaning up garbage objects, and is why you can get OutOfMemoryErrors even when most of the heap is garbage.

With PhantomReference, this situation is impossible -- when a PhantomReference is enqueued, there is absolutely no way to get a pointer to the now-dead object (which is good, because it isn't in memory any longer). Because PhantomReference cannot be used to resurrect an object, the object can be instantly cleaned up during the first garbage collection cycle in which it is found to be phantomly reachable. You can then dispose whatever resources you need to at your convenience.

Arguably, the finalize() method should never have been provided in the first place. PhantomReferences are definitely safer and more efficient to use, and eliminating finalize() would have made parts of the VM considerably simpler. But, they're also more work to implement, so I confess to still using finalize() most of the time. The good news is that at least you have a choice.[..]las/archive/2006/05/understanding_w.html

The other valuable reference about object life cycle -[..]ormance/1st_edition/html/

Incorrect use of reference can cause GC issue -

one more related blog -[..]garbage-collector-and-reference-objects/

(google search) (amazon search)

Tue Feb 28 16:39:40 HKT 2017 From /weblog/java/performance


Free online GC log Analyzer -

Free online thread analyzer -[..]y-and-cpu-monitoring-tools-and-technique

(google search) (amazon search)

Wed Feb 15 17:35:52 HKT 2017 From /weblog/java/libraries


Discussion of difference Java base object to object mapper -[..]013/10/java-object-to-object-mapper.html

Some information about JOOQ -

(google search) (amazon search)

Tue Feb 07 23:18:45 HKT 2017 From /weblog/java/fundamental


How difference platform implement nanoTime() -[..]12/02/what-is-behind-systemnanotime.html[..]62/is-system-nanotime-completely-useless

Java timezone ID reference -[..]etrive-locale-and-timezone-from-request/[..]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. -[..]1/joda-time-the-future-of-java-datetime/[..]va-time-jsr-310-enhancements-java-9.html

(google search) (amazon search)

Tue Jan 03 09:45:40 HKT 2017 From /weblog/java/concurrency


Similar to Barrier -

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

When to use CountDownLatch, Semaphore, CyclicBarrier, Exchanger and Phaser -

(google search) (amazon search)

Tue Jan 03 09:42:59 HKT 2017 From /weblog/java/performance

option list

-XX:+PerfDisableSharedMem , prevent locking by sharedmem in linux -

How linkedin turn the GC -[..]ughput-and-low-latency-java-applications

Using generational & concurrent GC collector -[..]/04/ibm-jvm-tuning-gencon-gc-policy.html

Full VM option list :, update for Java7 -[..][..]ost-complete-list-of-xx-options-for.html

A simplified list for some frequency use options -[..]rbage-collector-guidelines-and-tips.html

HotSpot JVM garbage collection options cheat sheet -[..]spot-jvm-garbage-collection-options.html[..]va/javase/tech/vmoptions-jsp-140102.html

An example and story about effect of difference VM parameter affecting the performance -

Clear the code cache automatically with -XX:+UseCodeCacheFlushing -[..]time-for-long-running-java-applications/

Discussion about -XX:MinHeapFreeRatio parameter -[..]

The other detailed guide for VM parameters tuning -

Here is a more simple cookbook -

A outdated (1.4) , compehensive but still not really too detailed, overview of various GC tuning -

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

Some say is useful if you have huge memory

Some say below parameter keep GC in low pause
Some say below parameter are very optimal
-XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:NewSize=1200m -XX:SurvivorRatio=16[..]d.tss?thread_id=41258&ASRC=EM_NNL_347804
Some say those parameter is good

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


Generate dump with OOME - -XX:+HeapDumpOnOutOfMemoryError

GC log sample of -XX:+UseConcMarkSweepGC -XX:PrintFLSStatistics=1 -XX:+PrintGCDetails -

A case study of tuning VM GC parameters -[..]ld-you-trust-the-default-settings-in-jvm

Explanation for few performance related VM parameters -[..]ine-options-jvm-performance-improvement/

Show the exact vm flag that java using -[..]/looking-inside-a-jvm-xxprintflagsfinal/

For G1GC -[..]e-first-garbage-collector-tuning-flags-1

(google search) (amazon search)

Thu Dec 22 15:47:37 HKT 2016 From /weblog/java/fundamental


Detailed decision of arraylist and linkedlist, consist of a lot benchmark results, take a look if interested:

One bug from java HashMap explaining it can be difficult to achieve fail-fast -

Performance difference of difference collection -[..]0/12/what-is-faster-jvm-performance.html[..]/2011/07/14/java-collection-performance/

A treelist implementation -

Implement LRU cache using LinkedHashMap -[..]11/06/java-secret-lru-cache-in-java.html

Problem of using soft-reference for automate cache clean up -[..]

if it claims that an element is contained in it, this might be in error, but if it claims that an element is not contained in it, then this is definitely true. -

Comment of various collections library -

List of FAQ of Java collections -[..]lections-interview-questions-and-answers

Java Collections – Performance (Time Complexity) -[..]1/java-collections-performance-time.html

Performance improvement for HashMap for Java8 -[..]hashmap-performance-improvements-in.html

Introduction to GS collection -[..]s/gs-collections-examples-tutorial-part1[..]s/gs-collections-examples-tutorial-part2

removeEldestEntry, interesting function of linkedhashmap -[..]/prevent-your-caches-from-exploding.html

(google search) (amazon search)

Sat Dec 03 09:41:11 HKT 2016 From /weblog/java/libraries

code generation

DSL of code generation -[..]e-codemodel-to-generate-java-source.html

jannocessor/ -[..]8/java-code-generation-with-jannocessor/

Living in the Matrix with Bytecode Manipulation -[..]cles/Living-Matrix-Bytecode-Manipulation[..]cles/Living-Matrix-Bytecode-Manipulation

(google search) (amazon search)

Tue Nov 29 11:43:01 HKT 2016 From /weblog/java/features


We can link java source in javadoc page:[..]amere/Weblog/cool_javadoc_trick#comments[..]/inheriting-javadoc-method-comments.html

(google search) (amazon search)

Tue Oct 11 00:24:40 HKT 2016 From /weblog/java/libraries


Good thing about LogBack -[..]your-java-logging-with-7-logback-tweaks/

Configuring how exception stack traces appear in log entries using Log4J2 -[..]ies-using-log4j2-e3a3dc5e48bc#.vfx1l1jlr

(google search) (amazon search)

Thu Oct 06 23:58:24 HKT 2016 From /weblog/java/concurrency


ReentrantReadWriteLock -[..]loperworks/library/j-jtp10264/index.html

why it suppose to be faster than VM level lock -[..]sr.166-concurrency/2005-02/msg00031.html and a test about it -[..]r/2011/11/java-lock-implementations.html

Samples of how to use it, and how to write test cases about it -

Some useful VM parameter to tune the locks: -XX:+EliminateLocks , -XX:+DoEscapeAnalysis , -XX:+UseBiasedLocking -[..]locking-escape-analysis-for-dummies.html

Discuss about 3 difference lock for Java, bias, thin and fat -

Why using the read lock will make lock detector fail -[..]concurrency-hidden-thread-deadlocks.html

Basic of synchronization and locking -[..]about-synchronization-in-java-and-scala/

Better semaphore with striped api -

Comparing and discuss difference locking approach -

Compare performance behavior of RWLock, StampedLock and Optimistic lock -[..]ocks-vs-readwritelocks-and-synchronized/

Comparing sync and lock -[..]ase-study-in-analysing-latency-lock.html

(google search) (amazon search)

Fri Jul 29 15:20:32 HKT 2016 From /weblog/java/performance


How can jruby take advantage of hotspot -[..]nderstanding-jvm-jit-and-helping-it.html

Discussion about OOME -[..]01/14/jvm_lies_the_outofmemory_myth.html

How hotspot optimization ofoptimzate Polymorphism -

List of tools -

an issue of hotspot but haven't handle in 5 year -

A test for how hotspot inline method -[..]ggressive-is-method-inlining-in-jvm.html

Various JIT optimization that JVM doing -[..]uper-useful-jit-optimization-techniques/

(google search) (amazon search)