8178536: OOM ERRORS + SERVICE-THREAD TAKES A PROCESSOR TO 100%

Mon, 19 Jun 2017 22:49:52 +0000

author
poonam
date
Mon, 19 Jun 2017 22:49:52 +0000
changeset 8986
6470230caf2a
parent 8979
aad15df39b88
child 8987
9ffa0d7ed932

8178536: OOM ERRORS + SERVICE-THREAD TAKES A PROCESSOR TO 100%
Summary: Clear the pending OOM exception in SensorInfo::trigger()
Reviewed-by: mchung, dcubed

src/share/vm/services/lowMemoryDetector.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/services/lowMemoryDetector.cpp	Mon Jun 26 22:29:37 2017 -0700
     1.2 +++ b/src/share/vm/services/lowMemoryDetector.cpp	Mon Jun 19 22:49:52 2017 +0000
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -298,19 +298,41 @@
    1.11      Klass* k = Management::sun_management_Sensor_klass(CHECK);
    1.12      instanceKlassHandle sensorKlass (THREAD, k);
    1.13      Handle sensor_h(THREAD, _sensor_obj);
    1.14 -    Handle usage_h = MemoryService::create_MemoryUsage_obj(_usage, CHECK);
    1.15 +
    1.16 +    Symbol* trigger_method_signature;
    1.17  
    1.18      JavaValue result(T_VOID);
    1.19      JavaCallArguments args(sensor_h);
    1.20      args.push_int((int) count);
    1.21 -    args.push_oop(usage_h);
    1.22 +
    1.23 +    Handle usage_h = MemoryService::create_MemoryUsage_obj(_usage, THREAD);
    1.24 +    // Call Sensor::trigger(int, MemoryUsage) to send notification to listeners.
    1.25 +    // When OOME occurs and fails to allocate MemoryUsage object, call
    1.26 +    // Sensor::trigger(int) instead.  The pending request will be processed
    1.27 +    // but no notification will be sent.
    1.28 +    if (HAS_PENDING_EXCEPTION) {
    1.29 +       assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOME here");
    1.30 +       CLEAR_PENDING_EXCEPTION;
    1.31 +       trigger_method_signature = vmSymbols::int_void_signature();
    1.32 +    } else {
    1.33 +       trigger_method_signature = vmSymbols::trigger_method_signature();
    1.34 +       args.push_oop(usage_h);
    1.35 +    }
    1.36  
    1.37      JavaCalls::call_virtual(&result,
    1.38                              sensorKlass,
    1.39                              vmSymbols::trigger_name(),
    1.40 -                            vmSymbols::trigger_method_signature(),
    1.41 +                            trigger_method_signature,
    1.42                              &args,
    1.43 -                            CHECK);
    1.44 +                            THREAD);
    1.45 +
    1.46 +    if (HAS_PENDING_EXCEPTION) {
    1.47 +       // We just clear the OOM pending exception that we might have encountered
    1.48 +       // in Java's tiggerAction(), and continue with updating the counters since
    1.49 +       // the Java counters have been updated too.
    1.50 +       assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOME here");
    1.51 +       CLEAR_PENDING_EXCEPTION;
    1.52 +     }
    1.53    }
    1.54  
    1.55    {

mercurial