• Stars
    star
    176
  • Rank 210,115 (Top 5 %)
  • Language
    C
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Terminate the JVM when resources are exhausted

Overview

jvmkill is a simple JVMTI agent that forcibly terminates the JVM when it is unable to allocate memory or create a thread. This is important for reliability purposes: an OutOfMemoryError or thread creation failure will often leave the JVM in an inconsistent state. Terminating the JVM will allow it to be restarted by an external process manager.

It is often useful to automatically dump the Java heap using the -XX:+HeapDumpOnOutOfMemoryError JVM argument. This agent will be notified and terminate the JVM after the heap dump completes.

Building

make JAVA_HOME=/path/to/jdk

Usage

Run Java with the agent added as a JVM argument:

-agentpath:/path/to/libjvmkill.so

Alternatively, if modifying the Java command line is not possible, the above may be added to the JAVA_TOOL_OPTIONS environment variable.

Alternatives

Newer JVMs (8u92+) support the -XX:ExitOnOutOfMemoryError option to exit on out of memory. Unfortunately, this option does not cover thread creation failure, therefore we still recommend using this agent. It is fine to use the agent in combination with this JVM option.

For older JVMs, a common alternative to this agent is to use the -XX:OnOutOfMemoryError JVM argument to execute a kill -9 command. Unfortunately, the JVM uses the fork() system call to execute the kill command and that system call can fail for large JVMs due to memory overcommit limits in the operating system. Additionally, as with -XX:ExitOnOutOfMemoryError, this does not cover thread creation failure.

More Repositories

1

airline

Java annotation-based framework for parsing Git like command line structures
Java
848
star
2

airlift

Airlift framework for building REST services
Java
564
star
3

aircompressor

A port of Snappy, LZO, LZ4, and Zstandard to Java
Java
530
star
4

slice

Java library for efficiently working with heap and off-heap memory
Java
498
star
5

drift

An annotation-based Java library for creating Thrift serializable types and services.
Java
235
star
6

procname

Set process name for Java on Linux
C
96
star
7

codestyle

Code style for Airlift projects
66
star
8

bytecode

High-level Java library for generating JVM bytecode
Java
61
star
9

discovery

Discovery Server
Java
53
star
10

airbase

Base POM for Airlift
47
star
11

airship

Airship is a software deployment and management tool
Java
32
star
12

command

Convenience library for executing external processes
Java
18
star
13

stackfold

Fold related stacks in Java thread dumps
Java
13
star
14

units

Java library for immutable human-friendly units
Java
12
star
15

testing-postgresql-server

Embedded PostgreSQL server for use in tests
Java
9
star
16

testing-mysql-server

Embedded MySQL server for use in tests
Java
7
star
17

astack

Capture JVM thread dumps without requiring safepoints
C++
6
star
18

parameternames

Utility methods for fetching Java method or constructor parameter names
Java
6
star
19

floatingdecimal

Fix monitor contention issues in OpenJDK's FloatingDecimal
Java
5
star
20

resolver

Resolve the dependencies of Maven coordinates or POM file
Java
5
star
21

airlift-rack

Airlift Rack
Ruby
3
star
22

gcwatch

Monitor the JVM for stop-the-world GC pauses
C++
3
star
23

junit-extensions

Extensions for JUnit 5
Java
1
star
24

joda-to-java-time-bridge

Java
1
star