function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GaneeeshGaneeesh 

How can i achieve this.. View state Error...?

Even though i am using "Transient" Key word VF page shows an Error "Maximum view state size limit (135KB) exceeded". Then what do i have to do.? How can i rectify this error.? 

Deepa.B.AnkaliDeepa.B.Ankali
@Ganeeesh,

If you are making use of a Visualforce Page, make use of html tags more than apex tags. (If you find that 'Internal' element in view state is occupying more memory). For the controller, make use as less variables as possible. As in if you are using 2 lists in which each contains thousands of same records, try to change your logic such that you make use of a map which altogether there would be thousand records instead of 2000 records.
Ashish_SFDCAshish_SFDC

Hi Ganesh, 

 

 

Viewstate is like the memory used to store the Current Field Values on the Current Visualforce Page. 

 

The view state size of your Visualforce pages must be under 135KB. By reducing your view state size, your pages can load quicker and stall less often.
 
You can monitor view state performance through the View State tab in the development mode footer and take the following actions:
 
Use only one <apex:form> tag on a page. Each <apex:form> adds a copy of the view state to the page, so extra forms multiply the data that needs to be loaded. You can also use the <apex:actionRegion> tag to submit form data from specific sections of the Visualforce page.
 
Use the transient keyword in your Apex controllers for variables that aren't essential for maintaining state and aren't necessary during page refreshes.
 
If you notice that a large percentage of your view state comes from objects used in controllers or controller extensions, consider refining your SOQL calls to return only data that's relevant to the Visualforce page.
 
If your view state is affected by a large component tree, try reducing the number of components your page depends on.

 

See the links below to understand the best practices, 

 

http://wiki.developerforce.com/page/An_Introduction_to_Visualforce_View_State

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_best_practices_performance.htm

 

http://www.salesforce.com/docs/en/cce/salesforce_visualforce_best_practices/salesforce_visualforce_best_practices.pdf

 

 

Regards,

Ashish