Imagine you have a symmetric key in heap memory, you no longer need it but you want to make sure it is wiped before the memory is released/garbage collected. If you wipe it yourself, the optimiser is likely to skip this step as unnecessary. So, how to do it properly?
I think this blog post should get you started. It seems to be about Swing, but I don't see why you couldn't apply it generally.