# HG changeset patch # User drwhite # Date 1462205666 14400 # Node ID 4e2bff1a546750612b0f53e403c22f1a4d638f7a # Parent f611c50b87038a12179228a41355e7b2ee5737e3 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 diff -r f611c50b8703 -r 4e2bff1a5467 hotspot/src/share/vm/runtime/vm_version.cpp --- 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; }