compareTo(Object o) behavior when you cannot convert argument to the expected type is to throw ClassCastException.
Perm Gen Space: Classes are stored here. And this space is ot included in the Heap Size. When classes that are no longer are not released this causes the Perm Gen Space to leak.
Typically an Object refers it’s class which refers it’s class loader and a class loader itself refers other classes. So if we have Long Running Threads (that doesn’t respond to shutdown events) or Loaded Drives then that means they can cause the Perm Gen to Leak.