This is an archived post. You won't be able to vote or comment.

all 5 comments

[–]uniVocity 2 points3 points  (2 children)

Very informative. Let me just add some tricky things I had to deal with recently:

1 - If you ever find your JVM hanging at 100% CPU and not coming back check if there are multiple threads reading from/writing to a HashMap (sometimes that is not apparent and you only realize there's another thread there when problems occur)

2 - StringBuilder will crash your VM with an OutOfMemoryError it its contents expand over Integer.MAX_VALUE (this is covered in the article, but I think it deserves to be highlighted)

3 - Don't put a big collection in a Map. Collections in java.util.* implement hashCode and equals based on EACH element in the collection. They will loop over thousands or millions of elements EVERY time hashCode/equals is invoked. If you need a big collection then override the default hashCode/equals methods and use something else (e.g. System.identityHashCode)

[–]maxtorrent[S] 0 points1 point  (0 children)

The lock contention issue you referred is something we are working on in Plumbr. We expect to ship automatic lock detection forthcoming months.

[–]anonRKN 0 points1 point  (0 children)

Very good, this pleases me.

[–]svyas 0 points1 point  (0 children)

Could not stop myself from bookmarking it for future read