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
Platy ITPlaty IT 

Reducing the size of the Internal node of the View State

I'm hitting "Maximum view state size limit (135KB) exceeded" errors when certain actions are performed on my page.  When I look at the View State, about 95% of the content comes from Internal.  I have tried adding "transient" to the few variables that could potentially get large, though right now I'm only dealing with data from 63 records in just a few fields (no blobs or long text fields even).  Any tips on what I can do to reduce that View State, or track down what's causing it?

 

Best Answer chosen by Admin (Salesforce Developers) 
MiddhaMiddha

HI Jessie,

 

You said you have already tried using the transient keyword. View state is nothing but a persistent state that a VF page tries to maintain and make it available when the page is reloaded or redirected. It saves all the values in the form tag those are not transient. 

 

Are you querying a big number of fields for these 63 records and getting them all on the page. Can you reduce the number of fields here.

 

You should check again if you have any variables in the class that you do not want when the page is reloaaded or redirected and you can make  them all transient. Also make the apex form as smaller as possible so that you dont have components in the form tag, those can be avoided.

All Answers

MiddhaMiddha

HI Jessie,

 

You said you have already tried using the transient keyword. View state is nothing but a persistent state that a VF page tries to maintain and make it available when the page is reloaded or redirected. It saves all the values in the form tag those are not transient. 

 

Are you querying a big number of fields for these 63 records and getting them all on the page. Can you reduce the number of fields here.

 

You should check again if you have any variables in the class that you do not want when the page is reloaaded or redirected and you can make  them all transient. Also make the apex form as smaller as possible so that you dont have components in the form tag, those can be avoided.

This was selected as the best answer
Platy ITPlaty IT

Thanks Gulshan.  Ultimately it ended up being one custom component that wasn't even being loaded when I was getting the error, and strangely when I copied the content of that component directly into the page, no more view state error.  Forced me to make my page a lot more efficient so it was a good learning exercise if nothing else :)