Monday 23 July 2012

JVisualVM

"Premature optimization is root of all evil" - I agree with that as mush as I can. But there are times, that you just need to make you code work faster. Joshua Bloch in his Effective Java is has put some light also to this area, for example in Item 5: Avoid creating unnecessary objects or 51: Beware the performance of string concatenation, etc. You can surely call them good practices that have to be known (and ofc most of things that this book is about).

But sometimes knowing basics is not enought, or project is too big to look deeply to every line of code, and  you just need to spot bottle neck quickly... What you need then? Java profiler! 


Guess what... - it's already with SDK (open consone + type jvisualvm), so no aditional effort is needed! Isn't that awesome? :)

Some performance issues in my current work, and especially reading AMA with high performance java code writer were eye openers for me... I will not pretend to be guru, and give you tips how and when you profiler - I'll just provide you with some link, that look permanent, and were enough to start effectively testing my application today's morning.

http://blog.xebia.com/2008/09/15/loitering-objects-make-web-company-lose-money/ - very pleasant to read blog entry, that forced me to try it all on my own - I couldn't write it better, so I don't event try :)

https://blogs.oracle.com/nbprofiler/entry/profiling_with_visualvm_part_1 - less blog-like, slightly less chilling, but this1 has some info that I found missing in previous link.

Both readings combined seems to be even more then you need to try it yourself, with pretty good knowledge what are you doing.

EDIT:
Feel the power of community! ;) - link provided by my mate (thanks Marcin!), that seems to be perfectly fetting in here - Eclipse Memory Analyzer - fast and feature-rich Java heap analyzer that helps you find memory leaks and reduce memory consumption. This time he seems to be knowing what he's talking about, so this tool should be worth the effort to know more about its capabilities. ;)

1 comment:

  1. I could also recommend Eclipse Memory Analizer http://wiki.eclipse.org/index.php/MemoryAnalyzer
    To check heap java dumps ;)

    ReplyDelete