Tuesday, November 10, 2009

How to free from incubus of Out of memory - java.lang.OutOfMemoryError: PermGen space

This blog will contain

What is permgen space memoty in JVM ?


Scenarios when java.lang.OutOfMemoryError: PermGen space may occur -

How to prfile the memory for such situation -

What are remedies with pros and cons -


Now you are free from incubus of java.lang.OutOfMemoryError: PermGen space

----- JVM Ghost exorcist ( Wizard - Nilesh Salpe )

How to pass parameters in request - Java server Faces ?

use utility class like ==>

 package com.salpe.util; 
import javax.faces.context.FacesContext;
public class FacesUtil{
/** * @param key
* @return */
public static Object getRequestParameter(String key) {
return FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get(key);
}
/** * @param key
* @param value */
public static void setRequestParameter(String key, Object value) {
FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put(key, value);
}
}

Then in any backing bean :

 package com.salpe.authentication.managedbeans; 
import com.salpe.util;
public class LoginPageBean {
LoginPageBean (){
}
// Action button for submit on login page
public actionSubmit(){
// Do anything logical
FacesUtil.setParameter("backPage" , "FromLoginPage")
return "welcomePage" ;
}
}

 package com.salpe.managedbeans; 
import com.salpe.util;
public class WelcomeBean{
WelcomeBean(){
String fromPage = FacesUtil.getParameter("backPage")
System.out.println( " Came from " + fromPage );
}
}