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
Ashritha ReddyAshritha Reddy 

can any one expalin this regarding view state?

If you notice that a large percentage of your view state comes from objects used in controllers or controller extensions, consider refining your SOQL calls to return only data that's relevant to the Visualforce page.
It means that you need to filter your queries to return only those records which are relevant to the vf page. Avoid storing such records which are not used anywhere
Chris  ByromChris Byrom
The first thing to remember is, anything that is created and stored in your controllers must be sent down the line to the browser. So if your controller is doing a lot of different queries and storing lots of information, that you don't display directly on the page, your view state can get bloated with unnecesary objects. To combat this you can do several things.
  1. Don't perform unneeded queries. If you don't need the data, there is no reason to fetch it. :)
  2. Don't store data in class-wide variables if you don't need to. Let's say you are going to need to look up a bunch of contacts and update them because the account page you are working on requires you to set a field on all contacts if a certain checkbox is checked. In this case don't get the contacts in your controller constructor, get it in the action behind your save button, and only use it in that method. This will prevent your page from having to store all that contact data needlessly. (Forget for the moment, that this scenario, is probably not the right way to bulk update your contacts.)
  3. Only get the fields you need. As you know, SOQL requires you to specify the fields to return. Don't add fields into your queries your page doesn't need to display or work with.
  4. Determine when you are planning your page, if you are going to be likely to break view state. Sometimes customers demand that more data be displayed than the view state can handle. No matter what you tell them, they demand that they be able to see 5,000 Opportunities with 20 fields on this single page. While that is an exageration, it doesn't really take that much to move beyond the limit. If this is the case for your use case you will need to find another solution for displaying your data. A couple of options are:
    1. The Standard Set Controller - This can be used to work with larger data sets and handle paging, etc.
    2. JavaScript Remoting - I have used this to handle retrieving and processing larger bits of data than the view state can handle in the past.