After upgrading to java buildpack 4.0+, applications that previously ran with smaller memory limit are now getting the error "insufficient memory".
Error Message:
2017-08-11T18:26:19.30+0000 [APP/PROC/WEB/0]ERR Cannot calculate JVM memory configuration: There is insufficient memory remaining for heap. Memory limit 512M is less than allocated memory 673748K (-XX:ReservedCodeCacheSize=240M, -XX:MaxDirectMemorySize=10M, -XX:MaxMetaspaceSize=93144K, -XX:CompressedClassSpaceSize=17404K, -Xss1M * 300 threads)
Java buildpack 4.0 has an enhancement to the JVM memory calculation and the new memory calculator now accounts for several different memory regions.
One major result of accounting for all of these memory regions is the likelihood that applications which previously ran in small containers (512M or less) will be unable to run.
The simplest and recommended solution to this problem is to increase the available memory to your application.
This can be done via "cf scale" command:
cf scale APP_NAME [-i INSTANCES] [-k DISK] [-m MEMORY] [-f]
Example:
cf scale my-application -m 1G