cloudfoundry / jvmkill

Terminate the JVM when resources are exhausted
Apache License 2.0
30 stars 11 forks source link

Kill threshold #1

Closed rafaelri closed 8 years ago

rafaelri commented 8 years ago

Make the JVMKill agent configurable in the sense that a single resourceExhausted event won't cause the JVM to be terminated.

Issues: #156

rafaelri commented 8 years ago

@nebhale I've decided to do the changes in increments. This commit covers the threshold (and a few tests for the agent). I did a regular C application to test the agent (without anything as fancy as cmocka but it seems to suffice). If you and @Zteve think it is fine I think we can move on with the thread dump. One thing to notice is that at least here in my tests the heapdump seems to be created by the VM itself. See the log I got while running a test that involves the VM and a custom crafted java class:

..........java.lang.OutOfMemoryError: Java heap space
Dumping heap to java_pid21878.hprof ...
Heap dump file created [2288332 bytes in 0,023 secs]

Isn't it possible to have something collect that file (probably the script that already respawns the VM) ?

rafaelri commented 8 years ago

Forget the comment about the heapdump, it is the -XX:+HeapDumpOnOutOfMemoryError on the Makefile. My fault, coding and watching NHL probably leads to this...

glyn commented 8 years ago

@rafaelri I tried to build this on Mac OS X and got:

$ make JAVA_HOME=$JAVA_HOME
==============================================
g++ -Wall -Werror -fPIC -std=c++11 -shared -fno-strict-aliasing -Wl,-soname=libJvmKill -static-libgcc  -fno-omit-frame-pointer -I"/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home//include" -I"/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home//include/darwin" -o libjvmkill.so jvmkill.c
clang: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated
clang: error: unsupported option '-static-libgcc'
make: *** [build] Error 1

Any chance you could support Mac OS X?

rafaelri commented 8 years ago

@glyn probably not cause I am without a Mac right now. I have plans of acquiring one but won't happen soon. :(

2016-02-29 9:44 GMT-03:00 Glyn Normington notifications@github.com:

@rafaelri https://github.com/rafaelri I tried to build this on Mac OS X and got:

$ make JAVA_HOME=$JAVA_HOME

g++ -Wall -Werror -fPIC -std=c++11 -shared -fno-strict-aliasing -Wl,-soname=libJvmKill -static-libgcc -fno-omit-frame-pointer -I"/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home//include" -I"/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home//include/darwin" -o libjvmkill.so jvmkill.c clang: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated clang: error: unsupported option '-static-libgcc' make: *\ [build] Error 1

Any chance you could support Mac OS X?

— Reply to this email directly or view it on GitHub https://github.com/cloudfoundry/jvmkill/pull/1#issuecomment-190195911.

glyn commented 8 years ago

@rafaelri Ok, thanks, I'll investigate.

glyn commented 8 years ago

@rafaelri This commit avoids compile/link errors and makes the tests pass on Mac OS X.

glyn commented 8 years ago

Also because I will only be spending one day per week on this, I made some notes in the wiki about Mac OS Support.

glyn commented 8 years ago

@nebhale has confirmed that @rafaelri provided a CLA.