Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

As of Winter '14 the Script Statement limit was replaced by a Maximum CPU time limit.

0
votes
3answers
55 views

Avoid 'Apex CPU time limit exceeded' with Batch Process

I encountered this error and have trouble with performance tuning. I tried asyncronous approach, but Apex CPU time limit exceeded occurs continuously. Anybody can make it more efficient? Here is ...
2
votes
1answer
29 views

Transactional governor limits and managed pacakges

My company is looking to install a very large managed package into our org, which has a significant amount of custom apex as well as several other large managed packages. As we test the package in ...
15
votes
4answers
862 views

Why are foreach loops slower in Apex than standard for loop?

Considering the following test class: @IsTest private class ProfilingTest { private static String TEST_STR = ''; public static testMethod void testForEachLoop(){ List<Account> ...
5
votes
1answer
378 views

Writing too much to debug log increases heap and cpu time

I have just observed that writing to debug log using System.debug increases heap size as well as CPU time. Is this normal. Please see the screenshot below for the comparison. The first one with so ...
0
votes
1answer
26 views

Report from Custom CSV Visualforce hits CPU Limit but works after reloading page

I have a Visualforce page that exports a custom CSV File. This report is very big and have a lot of processing on it thus causing sometimes CPU Limit. The problem is that for some users always on the ...
5
votes
1answer
348 views

Apex - Getting list of dates in month - CPU timeout

I am getting a CPU timeout from my loop. I have checked the debug logs and my start and end dates have the correct dates in them. I have tried setting the condition to be dtoday.adddays(3) just as a ...
0
votes
0answers
76 views

Apex Cpu Limit Exceeded Error in trigger

I have written trigger in salesforce code,it is already bulkified,But i am getting cpu limit exceeded error,while updating 200 records using Workbench Trigger code: trigger AccountTrigger on Account ...
1
vote
1answer
272 views

Apex CPU time limit exceeded for custom CommissionUpdate trigger

We have a custom trigger, CommissionUpdate, that causes an Apex CPU time limit error whenever we try to mass update records on the Account. I'm not a developer, and so I have no idea why this trigger ...
0
votes
1answer
112 views

Apex CPU time limit exceeded and An unexpected error has occurred. Your development organization has been notified

When I try to deploy on my production environment I receive the following error message: Apex CPU time limit exceeded and An unexpected error has occurred. Your development organization has been ...
0
votes
2answers
56 views

For Loop within For Loop.How to avoid such situation?

For Loop within For Loop.How to avoid such situation: I have a requirement where I am updating Parent Object(NCR__c) Status Value based on the Status of Child object(NCR_Task__c) Value. Scenario 1: ...
0
votes
1answer
128 views

How to overcome Apex CPU time limit exceeded exception

I'm updating the cases field values that are associated to an account using after update trigger. But one account is having 366 cases to it in which I'm facing Apex CPU time limit exceeded exception ...
1
vote
1answer
49 views

Hitting CPU Limit using BusinessHours

I am working on a method that adds business days using the BusinessHours class. Here is the method I'm working on: public static Date addBusinessDays(Date d, integer dayDifference, Id ...
0
votes
1answer
189 views

CPU Time Limit Exceeded for managed package

We are facing the CPU Time Limit Exceeded issue when loading an simple VisualForce Page. It is managed package which has also been installed in other orgs. While it works out find in other orgs(~...
2
votes
0answers
199 views

How to Avoid exceeding CPU Time Limit in Test Classes?

I am currently updating test classes in our org and it seems that most of them are exceeding the CPU Time Limit. They are using the @testSetup to create a lot of test data and it seems that these DML ...
0
votes
1answer
51 views

CPU Time Limit Exceeded in Trigger

Getting CPU time limit exceeded issue in trigger level. Trigger code: list<depot__c> depotList = new list<depot__c>(); for(Depot__c depot : Trigger.new){ depotList.add(depot); } ...
0
votes
1answer
45 views

Getting CPU time error

I tried to make use of maps but still getting CPU time error. Code: //@AuraEnabled public static Map<String, Integer> getDateRangeMap() { Map<String, Integer> mapToReturn = new Map&...
0
votes
2answers
39 views

Iterating with Map with Keys vs Values . Which is more efficient?

Iterating with Map with Keys vs Values : As in Apex we need to write code efficiently for avoiding memory issues and CPU time limit everywhere, I need to understand how to iterate over a map ...
0
votes
1answer
57 views

managing 'cpu limit exceeded' for slow future jobs

So currently I have a future method that queries all the fields of an object and queries a large chunk of data, then does some nested for loops to map out field usage. The problem is once it is used ...
0
votes
1answer
116 views

how to increase APEX REST inbound call cpu time limit

I have created a Apex Rest class, which is publicly exposed. I wanted to test cpu time limit for inbound call and found that it is 16 -20 sec. Is there any way by which I can increase cpu time ...
0
votes
1answer
348 views

How to solve my System.LimitException: Apex CPU time limit exceeded

I received the following error message during a validation process when I try to deploy my code on my production environment: System.LimitException: Apex CPU time limit exceeded Although the ...
3
votes
1answer
124 views

Do governor limits like Apex CPU time limit apply to @testSetup methods?

I have a test method written by a third party that occasionally results in Apex CPU time limit errors. The part of the method that includes setting up a semi-large amount of data on multiple objects (...
5
votes
3answers
193 views

Apex CPU time limit exceeded

I am experiencing an Apex Cpu Limit and as per checking am I correct that it is in the opportunitytrigger? shoudl I optimize it more? if(Trigger.isBefore){ if(Trigger.isInsert){ ...
0
votes
1answer
276 views

Apex CPU time limit exceeded in Apex batch class

I have below apex batch class where I am getting below error. Can someone please let me know where I am wrong to get such an error. Moreover, I get the parent record for ...
0
votes
0answers
37 views

Salesforce CPU limit exception : Environment dependent

I am getting CPU limit exception with StackTrace as only (Vendavo). But this only comes when I run the test from Apex Test Execution window from the organisation. Whereas when ran from Illuminated ...
1
vote
0answers
85 views

Unit Testing System.LimitException: Apex CPU time limit exceeded

I'm getting an error I've not seen before when running Unit Tests both synchronously asynchronously System.LimitException: Apex CPU time limit exceeded I know this error means that whatever ...
0
votes
0answers
184 views

Apex CPU time limit exceeded with big JSON object

Today I was working extracting information from a JSON object. I'm using jsonToken to navigate and get the values. When I have a JSON with 300 or less objects, I have no problem but when the JSON has ...
0
votes
0answers
17 views

loading bulk data for testing gives : System.LimitException: Apex CPU time limit exceeded

I am trying to test my batch process by loading bulk data: I am creating the data as follows: List<Account> accounts = new List<Account>(); List<Account_Plan__c> ...
0
votes
1answer
144 views

Apex CPU time limit exceeded - How to optimize the code with nested FOR loop?

I have an object A whose records have to be exported in .dat file format. I have a custom setting with the following three fields: Name (Standard field), Field API Name and Sort Order. All the fields ...
1
vote
1answer
90 views

Trigger hitting CPU Limit

I've just written my second trigger and it seems that I'm needing to learn more about how to optimize my code. My trigger runs through the campaign members of a campaign and changes the member status ...
0
votes
2answers
364 views

Can you execute batches in a visualforce flow?

Is it possible to create a collection via a visualforce flow and then update batches of a certain size until complete? Example: Flow is kicked off when an account is updated. Create a collection of ...
0
votes
1answer
227 views

CPU time out error

Getting CPU time out error for below code: Public class ResponseTimeCal { Public boolean isFirst= True; Public DateTime BalVar; Public long BalHours; Public Long seconds,minutes,hours,...
0
votes
0answers
63 views

How to remove loop inside loop for this case

I am doing trigger to fetch date conversion rate based on Opportunity Close Date and update opportunity field. The logic as below, as you notice I have to do loop inside loop in order to generate map ...
0
votes
2answers
34 views

CPU Limit While Inserting Contact Records Via Test Class - Workaround?

I'm writing my first batch class -- it looks for existing Contact records where AccountId is the Id of a dummy account and where the value in Company_Plain_Text_Field__c is a string-match to any ...
1
vote
2answers
86 views

PBR causes CPU limit errors — should I convert to a trigger?

I have a Process Builder Rule that looks for a change to a user lookup field on the Account. When it's changed, it reassigns every Contact within that Account to be owned by the new user. Problem is ...
25
votes
1answer
723 views

How can you benchmark Apex code to determine what operations consume the most CPU time?

There are multiple reasons why I'm asking this question, and I realize that it doesn't have an easy answer - accurately benchmarking code is difficult. I’m hoping I can craft this post in such a way ...
2
votes
1answer
296 views

System.LimitException: Apex CPU time limit exceeded Error on Account

We Have a certain Account Hierarchy designed in out Org.It display like this: Account(Top Account) ---Child Account 1 ----Child Account 1.1 ----Child Account 1.1.1 ...
0
votes
0answers
69 views

CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY: Contact_Trigger: execution of AfterUpdate caused by: System.DmlException: Update failed [duplicate]

This is my first time in here so I hope someone can help me on this. we are integrated with Marketo and we've been receiving a bunch of notification of this sort: ...
11
votes
1answer
83 views

Apex performance drops between Anonymous Apex and Trigger. Then further when using LMA login

Short version using approximate Apex CPU timings. Anonymous Apex can run a loop over 200 opportunities in ~10ms. The same loop in a trigger takes ~80ms. If you use an LMA login the trigger loop ...
2
votes
0answers
94 views

Need help with the error : : Apex CPU time limit exceeded

I am receiving error in the below lines of code when I pass more than 200 records in the list. For the fewer records it is working fine. Is there any way to optimize the code to avoid the error. ...
0
votes
1answer
51 views

VisualForce : Error CPU time limit exceeded in scheuled job

I have a scheduled job that sends page content via email, page controller needs about 15 sec to finish executing(looping over histories of more than one object) so sometimes scheduled job fails ...
1
vote
3answers
89 views

Trigger code Reduction

I have written the trigger code for skipping weekends and Holidays from Holiday custom object Trigger code: trigger ignoreweekends on order (before insert,before update) { for (order so : ...
1
vote
0answers
52 views

Profiling information shows a visualforce method executed for 35,256 ms. But the APEX CPU Limit is 10,000 ms

In the Execution logs, Profiling information shows a managed package visualforce method executed for 35,256 ms. But the APEX CPU Limit is 10,000 ms. How is that possible. PS. I am debugging APEX CPU ...
1
vote
1answer
247 views

Asynchronous calls from VF page to controller method

On a visualforce page that I created to upload documents, I tried to upload 500 documents at once. But it always exceeds the CPU time limit. Is there a way to invoke controller method Asynchronously ...
11
votes
1answer
262 views

Apex CPU time limit exceeded in tidy trigger pattern

I'm using Tony Scott's Tidy Trigger pattern for triggers. Suddenly, I'm facing CPU limit exception on trying to update 2k accounts. On checking the debug log I see that validation rules & ...
3
votes
2answers
988 views

Code Optimization

is there a way to optimized this code? I am having problem with bulk upload and these needs to be optimized, can you instruct me on what should be the proper way? I'm getting System.LimitException: ...
7
votes
1answer
454 views

Has anybody seen this behavior? Batch jobs failing silently on CPU timeout except in certain circumstances

There seems to be an issue with batch jobs failing silently when they exceed the CPU limit, except in certain circumstances. We have confirmed that this isn't just happening on my org but in one or ...
0
votes
1answer
60 views

Test method passes when run individually, but hits CPU limit when run with other methods

I'm working on an apex class that does the following: On a given record, compress field data from it and four child objects into CSV format on a long text field Export the compressed data to files in ...
11
votes
0answers
108 views

Programmatically detecting unpackaged metadata in org that depends on my package

My managed package is extensively customized and extended by some customers in their org. For our packaged objects they e.g. add Triggers + Custom Apex code Fields Validation Rules Workflows Process ...
0
votes
1answer
191 views

Apex CPU time limit exceeded when processing large number of records in a for loop

I ran into the CPU time limit exceeded error when processing the results of a SOQL query in a for loop. I tried several alternatives and nothing seems to help. Any help is greatly appreciated. Here ...
3
votes
1answer
70 views

CPU time limit error

I have one child object on account having lookup relationship, I want to update the average of some fields of child to parent, for this I wrote one after insert trigger on child. on doing bulk load I'...