Getting Stack Traces is SLOOOOWWWWWW
Posted by: Matt in Software development, tags: java, performanceI’ve recently been doing a lot of work with getting stack traces for a project I’m working on, and I’ve had what I sometimes call a “BGO” - Blinding Glimpse of the Obvious: getting Stack Trace information in Java is dead slow.
JDK 1.4 introduced the getStackTrace() method on Thread, which returns an array of StackTraceElement objects. This is way better than what had to be done previously, which was to generate a stack trace dump to a String-backed output stream and parse the dump, but underneath it all (and you can see this if you download the source for the JDK) it calls native code (fillInStackTrace()) to get the actual stack information for the thread. This is because threads are implemented natively using platform-dependent code that will not only vary by platform but by JVM vendor and version.
Read the rest of this entry »

Entries (RSS)