You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Determine whether we're on Heroku on a free, hobby, or 1x dyno.
86
+
#
87
+
# We set $HEROKU in the Procfile; we know we're on a baby dyno if the process limit is 256 per user.
88
+
#
89
+
# On a baby dyno we need to override the $JAVA_OPTS and give it a slightly lower memory limit because Heroku tends to think
90
+
# we can use more memory than we actually can. It defaults to giving us 300m but that still ends up going over the 512MB
91
+
# limit for the dyno. Set a few other additional options to minimize memory usage as well.
92
+
if [ -n"$HEROKU" ] && [ `ulimit -u`= 256 ];then
93
+
JAVA_OPTS="$JAVA_OPTS -Xmx248m"# This seems to be the right amount that prevents the dyno from going over the quota
94
+
JAVA_OPTS="$JAVA_OPTS -XX:-UseGCOverheadLimit"# Disable limit to amount of time spent in GC. Better slow than not working at all
95
+
JAVA_OPTS="$JAVA_OPTS -XX:+UseConcMarkSweepGC"# ConcMarkSweepGC seems to cause less OOM issues in my testing on low-mem Heroku envs
96
+
JAVA_OPTS="$JAVA_OPTS -XX:+CMSClassUnloadingEnabled"# Not 100% sure this does anything in Java 8 but if it does, we want to enable it
97
+
JAVA_OPTS="$JAVA_OPTS -XX:+UseCompressedOops"# Use 32-bit pointers. Reduces memory usage and GC events
98
+
JAVA_OPTS="$JAVA_OPTS -XX:+UseCompressedClassPointers"# Same as above. See also http://blog.leneghan.com/2012/03/reducing-java-memory-usage-and-garbage.html
99
+
fi
100
+
101
+
# Other Java options
102
+
JAVA_OPTS="$JAVA_OPTS -XX:+IgnoreUnrecognizedVMOptions"# Don't barf if we see an option we don't understand (e.g. Java 9 option on Java 7/8)
103
+
JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true"# don't try to start AWT. Not sure this does anything but better safe than wasting memory
104
+
JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"# Use UTF-8
105
+
JAVA_OPTS="$JAVA_OPTS --add-opens=java.base/java.net=ALL-UNNAMED"# Allow dynamically adding JARs to classpath (Java 9)
106
+
JAVA_OPTS="$JAVA_OPTS --add-modules=java.xml.bind"# Enable access to java.xml.bind module (Java 9)
0 commit comments