Actual VF Error- enter image description here enter image description here

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

  • 3
    What does view state have to do with compiling all classes? Can you edit this post to add more detail, and perhaps a screenshot?
    – Adrian Larson
    Mar 17, 2017 at 15:37
  • Adrian - When i click the compile all classes under apex classes, it just spins for a while and gives me this error. This is not an issue in other full sandboxes or production. Not sure why this is an issue with the dev sandbox.
    – Pratik
    Mar 17, 2017 at 15:42

1 Answer 1


This happens because the Apex Classes page is actually a Visualforce page (one managed by salesforce.com). Typically, this will happen when a utility class that's referenced by many other classes is altered in a way that either removes a method, changes the parameters or return type of the method, or a class was deleted. The error messages caused by failed compilation results in the view state exceeding the limit.

You won't be able to find the offending code without an offline tool of some sort. Basically, you need to pull out all the classes, then attempt to redeploy using "validate only." This will allow you to get a full list of compilation errors. I would suggest the metadata toolkit, since you can get all the compilation errors into a log file on your local computer.

The moral of the story is that you need to limit the use of globally used classes (sometimes referred to as "god classes"), because even a small, seemingly trivial change can cause the majority of your business logic to break all at once. Using utility classes in general is okay; it helps to keep your code DRY (Don't Repeat Yourself), but not at the expense of having one class that is a grab bag of unrelated features.

  • Wouldn't using Dev Console run all tests find this error?
    – cropredy
    Mar 18, 2017 at 5:21
  • 1
    @cropredy It will likely find most of the compilation errors, but there's no guarantee it will find all of them. I'd rather use the metadata API and make sure I find them all at once.
    – sfdcfox
    Mar 18, 2017 at 8:05

You must log in to answer this question.

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