@Override public String getMessage() { String message = super.getMessage(); StringBuilder sb = new StringBuilder(); sb.append( "Failed to allocate " ).append( attemptedAllocationSizeBytes ).append( " bytes. " ); sb.append( "So far " ).append( alreadyAllocatedBytes ); sb.append( " bytes have already been successfully allocated. " ); sb.append( "The system currently has " ); appendBytes( sb, getTotalPhysicalMemory() ).append( " total physical memory, " ); appendBytes( sb, getCommittedVirtualMemory() ).append( " committed virtual memory, and " ); appendBytes( sb, getFreePhysicalMemory() ).append( " free physical memory. " ); sb.append( "Relevant system properties: " ); appendSysProp( sb, "java.vm.name" ); appendSysProp( sb.append( ", " ), "java.vm.vendor" ); appendSysProp( sb.append( ", " ), "os.arch" ); if ( getCause() instanceof OutOfMemoryError ) { sb.append( ". The allocation was refused by the operating system" ); } if ( message != null ) { sb.append( ": " ).append( message ); } else { sb.append( '.' ); } return sb.toString(); }
@Override public String getMessage() { String message = super.getMessage(); StringBuilder sb = new StringBuilder(); sb.append( "Failed to allocate " ).append( attemptedAllocationSizeBytes ).append( " bytes. " ); sb.append( "So far " ).append( alreadyAllocatedBytes ); sb.append( " bytes have already been successfully allocated. " ); sb.append( "The system currently has " ); appendBytes( sb, getTotalPhysicalMemory() ).append( " total physical memory, " ); appendBytes( sb, getCommittedVirtualMemory() ).append( " committed virtual memory, and " ); appendBytes( sb, getFreePhysicalMemory() ).append( " free physical memory. " ); sb.append( "Relevant system properties: " ); appendSysProp( sb, "java.vm.name" ); appendSysProp( sb.append( ", " ), "java.vm.vendor" ); appendSysProp( sb.append( ", " ), "os.arch" ); if ( getCause() instanceof OutOfMemoryError ) { sb.append( ". The allocation was refused by the operating system" ); } if ( message != null ) { sb.append( ": " ).append( message ); } else { sb.append( '.' ); } return sb.toString(); }