I have a VF page where i am displaying the records from a custom object using different SOQL search statement. But when the number of record is getting more i am getting an error of View State. Which mean that VF page cannot hold that much records. How can i resolve it? Please guide me a best way to get this issue resolve.

1 Answer 1


The view state is primarily a serialised version of a) the non-transient fields of the controller class and b) the page component tree built by the Visualforce apex: tags.

You should find out which of these the problem is with starting from the "Examining the View State" section of An Introduction to Visualforce View State. That article also includes the common approaches to addressing the problem.

Also click on the viewstate tag here and browse the various postings on the subject.

The fix might be very simple e.g. instead of assigning your search results to a field just return them from a getter method.

  • +1 for returning from getter method. It's often unnecessary to actually store the data in view state if it's read only. Even if it's writable, you can usually use a getter and setter together to get the desired effect without much trouble.
    – sfdcfox
    Jun 15, 2014 at 9:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .