*   For reference, we added an OOM callback to then do whatever reporting we 
want to in that case in native;
  *   this allows us to be very careful of not trying to allocate things during 
an OOM.
  *

HI JC, what callbacks are you referring to  exactly  ?

Best regards, Matthias


From: JC Beyler <jcbey...@google.com>
Sent: Donnerstag, 20. September 2018 17:52
To: Baesken, Matthias <matthias.baes...@sap.com>
Cc: David Holmes <david.hol...@oracle.com>; serviceability-dev@openjdk.java.net
Subject: Re: OOM counters

Hi Matthias,

- hotspot-dev to be in two mailing lists

I'm still confused of why you want this via a Java API or why you want to look 
at those counters to begin with.
The JVM is going through an OOM, are you trying to do: your program detects it 
via a try/catch; then go to MemoryMXBean to see what OOM it was?

For reference, we added an OOM callback to then do whatever reporting we want 
to in that case in native; this allows us to be very careful of not trying to 
allocate things during an OOM.

Seems to me that with a callback, you can then do whatever you like, such as 
adding to your queue for other users to look at afterwards, no? What am I 
missing?
Jc

On Wed, Sep 19, 2018 at 11:43 PM Baesken, Matthias 
<matthias.baes...@sap.com<mailto:matthias.baes...@sap.com>> wrote:
Hi David , the values are already  user-inspectable via   jcmd   
vm.info<http://vm.info> ,  however this way is not very user friendly (and I am 
not sure how stable it is between updates / releases).
Probably not as stable as an API .

Best regards, Matthias



> -----Original Message-----
> From: David Holmes <david.hol...@oracle.com<mailto:david.hol...@oracle.com>>
> Sent: Donnerstag, 20. September 2018 03:13
> To: Baesken, Matthias 
> <matthias.baes...@sap.com<mailto:matthias.baes...@sap.com>>; 'hotspot-
> d...@openjdk.java.net<mailto:d...@openjdk.java.net>' 
> <hotspot-...@openjdk.java.net<mailto:hotspot-...@openjdk.java.net>>; 
> serviceability-
> d...@openjdk.java.net<mailto:d...@openjdk.java.net> 
> serviceability-dev@openjdk.java.net<mailto:serviceability-dev@openjdk.java.net>
>  <serviceability-
> d...@openjdk.java.net<mailto:d...@openjdk.java.net>>
> Subject: Re: OOM counters
>
> 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<http://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
> >


--

Thanks,
Jc

Reply via email to