Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions sdks/java/container/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ func main() {
"-XX:+UseParallelGC",
"-XX:+AlwaysActAsServerClassMachine",
"-XX:-OmitStackTraceInFastThrow",
// Crash and restart instead of throwing OutOfMemoryError which may be caught by user or
// framework code and leave things in a degraded state.
"-XX:+ExitOnOutOfMemoryError",
}

enableGoogleCloudProfiler := strings.Contains(options, enableGoogleCloudProfilerOption)
Expand Down Expand Up @@ -221,16 +224,18 @@ func main() {
args = append(args, jammAgentArgs)
}

enableHeapDumpsOnOom := false
// If heap dumping is enabled, configure the JVM to dump it on oom events.
if pipelineOptions, ok := info.GetPipelineOptions().GetFields()["options"]; ok {
if heapDumpOption, ok := pipelineOptions.GetStructValue().GetFields()["enableHeapDumps"]; ok {
if heapDumpOption.GetBoolValue() {
args = append(args, "-XX:+HeapDumpOnOutOfMemoryError",
"-Dbeam.fn.heap_dump_dir="+filepath.Join(dir, "heapdumps"),
"-XX:HeapDumpPath="+filepath.Join(dir, "heapdumps", "heap_dump.hprof"))
}
enableHeapDumpsOnOom = heapDumpOption.GetBoolValue()
}
}
if enableHeapDumpsOnOom {
args = append(args, "-XX:+HeapDumpOnOutOfMemoryError",
"-Dbeam.fn.heap_dump_dir="+filepath.Join(dir, "heapdumps"),
"-XX:HeapDumpPath="+filepath.Join(dir, "heapdumps", "heap_dump.hprof"))
}

// Apply meta options
const metaDir = "/opt/apache/beam/options"
Expand Down
Loading