View State in Salesforce

It is a state that holds tags, field values and all component of controller except transient type. The maximum size limit of visualforce page is 132KB. If the size increase it results in View state problem.

How to enable View State for User:

1. Write user in quick find
State Problem in Salesforce

2. Click on User link. It redirects to the page that having list of users.
3. Then, click on the user name.
4. Click on edit button and check the show View State in Development Mode checkbox.
State Problem in Salesforce

It displays at the bottom of the Visualforce page:
State Problem in Salesforce

How to avoid View State Problem :

a) Use transient type of variable.
b) Clear the collects that are not further use.
c) Query only that fields which are required.
d) Use pagination if you need to display large amount of data in the visualforce page table.