Wednesday 11 January 2017

How to solve Tomcat – java.lang.OutOfMemoryError: PermGen in Amazon Linux AMI

Tomcat web server often suffers from java.lang.OutOfMemoryError: PermGen space whenever you deploy and un-deploy your web application couple of time. 
In this article, we will see how to fix java.lang.OutOfMemoryError: PermGen Space in tomcat server.



1. Goto Tomcat startup script file location, for Amazon Linux AMI. It locates at "/etc/rc.d/init.d/"

2. Edit the script file by "sudo nano tomcat7"

3. Add the following JAVA_OPTS at the beginning of the file after "NAME="$(basename $0)""
export JAVA_OPTS="-Xms1024m -Xmx10246m -XX:NewSize=256m -XX:MaxNewSize=356m -XX:PermSize=256m -XX:MaxPermSize=356m"

You can change the actual heap size and PermGen Space as per your requirement.

4. Restart Tomcat.

Increasing PermGen space can prevent java.lang.OutOfMemoryError: PermGen in tomcat only for some time and it will eventually occur based on how many times you redeploy your web application, its best to find the offending class which is causing a memory leak in tomcat and fix it.

Sunday 1 January 2017

Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to

Recently always met this issue while using Android Studio, "Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to ..."

After Android Studio starts to support Instant Run, this issue becomes critical. If you want to use Instant Run, you should keep your gradle and gradle plugin version updated. 

First time I met this issue, I search online, luckily I can easily find the solution. But 2nd time is not so lucky, because the answer online is outdated. So the best solution is to know which version is the latest one, otherwise every time I need to waste a lot of time to find the solution.

So here is the solution.
Here is the link to check the latest version of gradle plugin.
https://jcenter.bintray.com/com/android/tools/build/gradle/

Example to apply to root level build.gradle file (Updated on 26 Jul 2017),
classpath 'com.android.tools.build:gradle:2.4.0-alpha7'


Here is the link to check the latest version of gradle.
Example to apply to gradle-wrapper.properties file (Released on 26 Jul 2017, updated on 26 Jul 2017),
distributionUrl=https\://services.gradle.org/distributions/g‌​radle-4.0.2-all.zip