About Peter Lawrey
List/Grid Author Archives Subscribe to the RSS feed of Peter Lawrey

Java Object resurrection
Overview After an object which overrides finalize() is collected it is added to a finalization queue to be cleaned up after calling the finalize() method of each object. By what happens ...

Performance of inlined virtual method invocations in Java
Overview One of the benefits of dynamic compilation it the ability to support extensive method inlining on virtual method code. While inlining the code improves performance, the code ...

When using direct memory can be faster
Overview Using direct memory is no guarantee of improving performance. Given it adds complexity, it should be avoided unless you have a compelling reason to use it. This excellent ...

Wasting time by saving memory
You might say that at my company, the hard ware is 10x more expensive, but it also likely you time is costing the company about the same more. In any case, this article attempts to ...

Java Intrinsics and Performance
The original question was How to count the number of 1′s a number will have in binary? I included a performance comparison of using Integer.bitCount() which can be turned into ...

Java Hidden code
Sometime ago I came across the issue of invisible characters in Strings. These can really cause confusion because they are invisible. String a = "Hello\u200e"; String b = ...

Java memes which refuse to die
Also titled; My pet hates in Java coding. There are a number of Java memes which annoy me, partly because they were always a bad idea, but mostly because people still keep picking ...

Odd practices in Java
Overview There are a number of practices in Java which oddly baffle me. Here are but a few. Using -Xmx and -Xms The option -Xmx is widely used to set the maximum memory size. As noted ...

Latency, Throughput and Degree of Concurrency
chrisapotek asked. How do you define throughput and latency for your test? There is not a simple question, so I have replied with a post. Sustained Throughput I consider throughput ...

Why Math.round(0.499999999999999917) rounds to 1 on Java 6
Overview There are two types of error representation error and arithmetic rounding error which are common in floating point calculations. These two error combine in this simple example, ...


