Java Performance Tuning

Java(TM) - see bottom of page

|home |services |training |newsletter |tuning tips |tool reports |articles |resources |about us |site map |contact us |
Tools: | GC log analysers| Multi-tenancy tools| Books| SizeOf| Thread analysers| Heap dump analysers|

Our valued sponsors who help make this site possible
JProfiler: Get rid of your performance problems and memory leaks! 

Training online: Concurrency, Threading, GC, Advanced Java and more ... 

News March 2017

Get rid of your performance problems and memory leaks!

Modern Garbage Collection Tuning
Shows tuning flow chart for GC tuning

Java Performance Training Courses
COURSES AVAILABLE NOW. We can provide training courses to handle all your Java performance needs

Java Performance Tuning, 2nd ed
The classic and most comprehensive book on tuning Java

Java Performance Tuning Newsletter
Your source of Java performance news. Subscribe now!
Enter email:

Training online
Threading Essentials course

Get rid of your performance problems and memory leaks!

Back to newsletter 196 contents

A colleague read about the Reference objects in an article linked to in last month's newsletter, and asked me about SoftReference based caches. My reply was that they were not very useful because of the non-deterministic way they evict, and that standard practice is to go for a limited sized cache with a specific eviction policy (like LRU). But he felt that the idea of a cache that was sensitive to memory-pressure seemed like a good idea. I suspect others do to.

A note from this newsletter's sponsor

New Relic - Try New Relic today and get your free Data Nerd shirt!
Free SaaS APMto monitor, troubleshoot, and tune apps
running on Websphere, Weblogic, Tomcat, Jetty, JBoss, Solr, Resin

While in principle it sounds good to have a memory-pressure sensitive cache, here's a description of it using SoftReferences. "Here's a cache for you. It provides a JCache API. If memory gets low, entries will be evicted. Entries might also be evicted if they're in the cache for too long. I can't say what too long is, because it kind of depends on the JVM and the memory at any time. Also, there's a possibility that entries can be evicted at other times too. Really any time at all. Actually, the only time I can guarantee the entry will NOT be evicted is if something else in the application is using the entry, ie there is a strong reference to the value. In those cases, even when memory is low, those entries won't get evicted. Also, you have no control over eviction, just leave it to the cache to decide." Does that really sound like an attractive cache to use?

If you really want to have memory-pressure sensitive cache, encapsulate your preferred cache and add separate functionality which detects memory pressure - you can have an explicit SoftReference which you periodically renew (the current JVM implementation has the lifetime of the SoftReference as a factor) and subclass the ReferenceQueue it gets added to so that you can trigger an action on your cache when it gets added. First check memory usage (if it's just done a GC, you may have loads free now), then maybe make the cache smaller, or dump it or ... something deterministic and appropriate to your application.

Now on to our links to tools, articles, news, talks, blogs. And if you need the tips from this month's articles and talks, as ever they are extracted into this month's tips page.


Java performance tuning related news.


Java performance tuning related tools.

A note from this newsletter's sponsor : Deep dive Application Performance Monitoring
Fix performance issues with Java, .NET and Ruby platforms
Monitor app instance at $12/Month. 30-day free trial. Sign Up!


Jack Shirazi

Back to newsletter 196 contents

Last Updated: 2022-11-29
Copyright © 2000-2022 All Rights Reserved.
All trademarks and registered trademarks appearing on are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries. is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
RSS Feed:
Trouble with this page? Please contact us