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

Visualforce Error - Maximum view state size limit

Visualforce Error

Help for this Page

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

Steven NsubugaSteven Nsubuga
Reduce the number of fields you are querying.
Use fewer components on your page.
Use the transient keyword where appropriate.
This link ( has some general guidelines.
Thank you Steven,
We are not querying any data we are just inserting data into the object.. there is no retrival. no SOQL as well just inserts..
and we have used fewer components and transients andy other clue
Steven NsubugaSteven Nsubuga
Why use a Visualforce page if all you are doing is a mere insertion? 
Perhaps your logic creates many objects, hence the increased memory usage and view state.
Consider splitting the logic and insertion into 2 pages, perhaps as a Visualforce 2 page wizard application.
you are right but the fields we have are too small to create multiple pages for it.. we are working with only one object and 18 fields with attachment..
checking view state in developer console, we are not even getting to 135KB. we have 6.36KB. Is this not a generic error where by there could be related to some other issues. before we got here, we were getting authorized required, and then we drilled down to this 135kb message...
Sohan Raj GuptaSohan Raj Gupta
Hi Stephen,

Can you share your VF and class code here?

Sohan Raj
Is there another way to do this Sohan?
@Steven I am assumnig it is big because I switched to the default UI.. I use salesforce/apex/application to run it locally that gave the error message
Hello.. I resolved the issue... it has nothing to do with UI or view state or authorization required.
These were generic messages...

This has to do with my field length being small and I saw this after perform a debug log.
field(20) was changed to field(100) to accomodate the number of characters. 
Thank you all