8134889: Kitchensink stress test crashes with out of memory error
Summary: Add a hard max of 16 GC threads (each for concurrent and parallel G1) on 32-bit JVMs.
Reviewed-by: mgerdin, pliden
--- a/hotspot/src/share/vm/runtime/vm_version.cpp Tue May 03 08:12:25 2016 -0700
+++ b/hotspot/src/share/vm/runtime/vm_version.cpp Mon May 02 12:14:26 2016 -0400
@@ -289,6 +289,7 @@
unsigned int switch_pt) {
if (FLAG_IS_DEFAULT(ParallelGCThreads)) {
assert(ParallelGCThreads == 0, "Default ParallelGCThreads is not 0");
+ unsigned int threads;
// For very large machines, there are diminishing returns
// for large numbers of worker threads. Instead of
// hogging the whole system, use a fraction of the workers for every
@@ -296,9 +297,20 @@
// and a chosen fraction of 5/8
// use 8 + (72 - 8) * (5/8) == 48 worker threads.
unsigned int ncpus = (unsigned int) os::active_processor_count();
- return (ncpus <= switch_pt) ?
- ncpus :
- (switch_pt + ((ncpus - switch_pt) * num) / den);
+ threads = (ncpus <= switch_pt) ?
+ ncpus :
+ (switch_pt + ((ncpus - switch_pt) * num) / den);
+#ifndef _LP64
+ // On 32-bit binaries the virtual address space available to the JVM
+ // is usually limited to 2-3 GB (depends on the platform).
+ // Do not use up address space with too many threads (stacks and per-thread
+ // data). Note that x86 apps running on Win64 have 2 stacks per thread.
+ // GC may more generally scale down threads by max heap size (etc), but the
+ // consequences of over-provisioning threads are higher on 32-bit JVMS,
+ // so add hard limit here:
+ threads = MIN2(threads, (2*switch_pt));
+#endif
+ return threads;
} else {
return ParallelGCThreads;
}