OOM counters
David Holmes
david.holmes at oracle.com
Thu Sep 20 01:12:38 UTC 2018
Hi Matthias,
Those counters, as I recall, were added to the hs_err report purely to
show if an application/test had been "playing too close to the edge"
before it crashed. They were never intended as user-inspectable values.
I have no opinion as to whether they should be.
David
On 19/09/2018 7:12 PM, Baesken, Matthias wrote:
> Hello, Currently we have already counters in the Hotspot codebase
> counting Java heap,
>
> Metaspace and class metaspace related OOMs.
>
> See declarations:
>
> jdk/src/hotspot/share/utilities/exceptions.hpp
>
> 107 // Count out of memory errors that are interesting in error diagnosis
>
> 108 static volatile int _out_of_memory_error_java_heap_errors;
>
> 109 static volatile int _out_of_memory_error_metaspace_errors;
>
> 110 static volatile int _out_of_memory_error_class_metaspace_errors;
>
> output :
>
> jdk/src/hotspot/share/utilities/exceptions.cpp
>
> 460void Exceptions::print_exception_counts_on_error(outputStream* st) {
>
> 461 print_oom_count(st, "java_heap_errors",
> _out_of_memory_error_java_heap_errors);
>
> 462 print_oom_count(st, "metaspace_errors",
> _out_of_memory_error_metaspace_errors);
>
> 463 print_oom_count(st, "class_metaspace_errors",
> _out_of_memory_error_class_metaspace_errors);
>
> 464 if (_stack_overflow_errors > 0) {
>
> 465 st->print_cr("StackOverflowErrors=%d", _stack_overflow_errors);
>
> 466 }
>
> 467 if (_linkage_errors > 0) {
>
> 468 st->print_cr("LinkageErrors=%d", _linkage_errors);
>
> 469 }
>
> 470}
>
> But currently the output is only done from vmError.cpp , in case of
>
> a) error reporting
>
> b) jcmd vm.info (in case exceptions happened, otherwise the section
> is not printed)
>
> (see void VMError::print_vm_info(outputStream* st) { ... } )
>
> It would be interesting for us to get the values of the existing
> counters via JDK coding.
>
> In our proprietary JVM we had a similar mechanism.
>
> Is there anything planned for this (or even already something present) ?
>
> There exists already a class java/lang/management/MemoryMXBean.java
> with a management interface for the memory system of
>
> the Java virtual machine. It contains some "getter" - methods like
>
> public int getObjectPendingFinalizationCount();
>
> public MemoryUsage getHeapMemoryUsage();
>
> Do you think we could add a method (or methods) for accessing the
> existing OOM counters
>
> ( for example, public OomCounters getOutOfMemoryCounters(); ) ?
>
> Best regards, Matthias
>
More information about the serviceability-dev
mailing list