+ Start a Discussion

Maximum view state size limit (135KB) exceeded.


 when am Executing the visualforcepage . here am using the Search Filter to display the Time sheet Record based on the Project we have selected  and am getting the view state Error

Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 135.875KB
Well seems like you are displaying to much data in your visualforce page.

Go through this page http://salesforce.stackexchange.com/questions/4537/how-to-reduce-a-large-internal-view-state-what-is-in-the-internal-view-state

You will get an Idea about the viewstate, what it is, how to reduce etc.

I am displaying 5664 records bt am using the pagination to display the 100 records  per page only,

when  am getting 5664 records  am getting the above  error

bt am able to display the 3800 records on the page using the pagination without an  view state error.

Can u say me  how to resolve it


I guess you are storing the records in a list. And a list is also a part of viewstate hence you are getting error.

yes i  have the soql query and am storing in a list .

then how to resolve my error .

Can u please suggesst me


As a workaround maybe you can use Javascript Remoting? I.e. get the records through javascript asynchronous calls and update the page. This won't add to viewstate as far as I know.


// Niklas


Can u please tell me how to use the javascript remoting  ? so that it may help me


Hi Avildev9,
thanks for ur reply
Can u suggest me how avoid the error for List

Remove the getter setter declaration from the list in which you are storing the soql records.

For ex -


private list <TimeSheet__c> listTsheets;
//getter setter removed and made private as this list will not be displayed on page



2 solutions. Look into the "transient" keyword which tells the controller to not include that giant list in the viewstate or switch to real pagination. Salesforce now supports the "OFFSET" keyword in SOQL which will allow you to page through the data like you normally would without have to load all items into a list and page through them. 


See this page for a good example of pagination in a visualforce page: http://www.redpointsolutions.com/add-pagination-to-your-visualforce-pages-using-the-soql-offset-clause

thanks for ur reply.
but we need to display on the page

What do you mean you need to display it on the page?