System.LimitException: Apex CPU time limit exceeded: meaning and how to fix it
Quick answer
System.LimitException: Apex CPU time limit exceeded: Apex code, triggers, flows and other automation in the transaction used more CPU time than allowed. Nested loops, heavy string work and many automations on one record are common causes. Start with: Use the debug log with limits and profiling to find the slow code.
Typical message: System.LimitException: Apex CPU time limit exceeded
Cause
Apex code, triggers, flows and other automation in the transaction used more CPU time than allowed. Nested loops, heavy string work and many automations on one record are common causes.
How to fix System.LimitException: Apex CPU time limit exceeded
- Use the debug log with limits and profiling to find the slow code.
- Replace nested loops over lists with Maps.
- Move long work to Queueable or Batch Apex.
- Check for many triggers, flows and process automation firing on the same object.
Have a different message? Paste it into the error decoder, which matches it against 45 common Salesforce errors in your browser.
Frequently asked questions
What does System.LimitException: Apex CPU time limit exceeded mean in Salesforce?
Apex code, triggers, flows and other automation in the transaction used more CPU time than allowed. Nested loops, heavy string work and many automations on one record are common causes.
How do I fix System.LimitException: Apex CPU time limit exceeded?
1. Use the debug log with limits and profiling to find the slow code. 2. Replace nested loops over lists with Maps. 3. Move long work to Queueable or Batch Apex. 4. Check for many triggers, flows and process automation firing on the same object.
More Governor limits errors
SFDX Talk is unofficial documentation. It is not affiliated with, endorsed by, or sponsored by Salesforce, Inc. Message text varies slightly by release and context, so confirm against the official page before relying on it.