Tuesday, July 1, 2014

What is Maximum view state size limit exceeded in Salesforce?

Error : Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 410.891KB.  


Step 1:
This will occurs when the variable is u declared as a public .So try to declare this variables as transient. Because this transient keyword used to declare instance variable that cannot be saved.

Step 2:
Open the view state and check which variable it taking the kilobytes, see if you can set that variable to null after rendering the page.

You have to enable view state from your personal information if its already not enabled.
If you edit your profile, there are two checkboxes – “development mode” and “show view state in development mode”.  If you check both of these, you will have access to the view state inspector.  However, if you are already exceeding the view state it may not be much help – you might need to reduce it before you can see it properly if you get  my meaning.

Step 3:
Example:
You will be using a variable to hold file data like this.
VF Page:

In Apex class:
public blob file{get; set;}
Use transient keyword before blob data type. like below,
public transient blob file{get; set;}
The transient keyword gives persistency in the VF page..

For more information please refer to the link:

How to enable view state in Salesforce
http://wiki.developerforce.com/page/An_Introduction_to_Visualforce_View_State
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_keywords_transient.htm
http://www.salesforce.com/us/developer/docs/pages/Content/pages_best_practices_performance.htm




0 comments:

Post a Comment

 
| ,