Stack Exchange Network

Stack Exchange network consists of 175 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

Questions tagged [cpulimit]

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

1
vote
2answers
56 views

Flow Error - Apex CPU Time Limit Exceeded

I have a flow that is supposed to update multiple Account records and then triggers a process builder to update their related Opportunities. This happens at the start of the new fiscal year to set up ...
0
votes
0answers
21 views

Processing CampaignMember object without hitting governor limits

Campaign is used to create parent campaign which is assigned to each term. Each parent gets set of child campaigns with parentId=null (that's how we distinguish between parent and child campaigns) ...
1
vote
2answers
59 views

How can I create 1500 contacts for my units tests without hitting CPU limit?

I am creating a script that gets run every quarter that checks for any paid status in campaignMember objects that has contactId attached, and update the status to unpaid and create a campaignMember ...
2
votes
1answer
30 views

Is there any ways to identify which managed packages most significantly consume our limits?

Our org is having trouble with our SOQL and CPU Time Limits. While it is probably true that our own legacy code could be bulkified better, this is a non-trivial, non-short term solution. Our org has ...
1
vote
3answers
70 views

Need help-apex cpu time limit exceeded

I scheduled an apex job to run daily at midnight but noticed that the job failed due to the Apex CPU time limit exceeded error. The code works in my developer sandbox but not in production. I'm ...
1
vote
1answer
115 views

Apex CPU Time Limit Exceeded error for DateMethods.Year()

I am getting Apex CPU time limit exceeded even though the listhistoricalList is small (has 14 Records in it). String soql = 'SELECT Id, Name, SoM_Business_Location_Status__c, SoM_Shipping_Address__c,...
2
votes
1answer
141 views

Alternative for lambda expressions in apex salesforce

I know that Salesforce does not support lambda expressions and query syntax (like in LINQ) queries in apex collections. But, It would be a nice feature for developers. Has anyone tried implementing ...
0
votes
1answer
36 views

Is there a better way to create related records when creating test data?

I am trying to create a large set of test data along with child records and this is what i came up with. Could anyone let me know if there's a better way to achieve the same? Integer countStart = ...
0
votes
1answer
104 views

How to avoid apex `CPU time limit exceeded` by using map based query?

I have the following piece of source code: List<Account> accountsList = ([SELECT id FROM Account]); for(Account account: accountsList) { List<CustomObject1__c> allCustomObjects1 = ([...
7
votes
1answer
98 views

Slow scratch orgs causing Apex CPU time limit to be hit about 20% of the time - any workarounds?

We have an SFDX build set up that runs our 2,800 tests against 6 different scratch org configurations in parallel. But every build fails on what seems like a random one of the scratch orgs (i.e. it ...
1
vote
2answers
71 views

Heap size LIMIT

I'm trying to reduce the heap size limit while a program is running - I'm doing it by taking the data (a list for example) and after I'm using it, I'm assigning the instance to a new List : Example: ...
0
votes
3answers
264 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 ...
4
votes
1answer
219 views

Transactional governor limits and managed packages

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
1k 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
687 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
32 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
354 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
168 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
329 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
230 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
66 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
186 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
65 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
333 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
334 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
59 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
53 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
49 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
108 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
173 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
784 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
195 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
321 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
453 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
41 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
120 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
260 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
237 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
132 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
565 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
302 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
66 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
38 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
125 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 ...
26
votes
1answer
1k 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 ...
1
vote
1answer
381 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 ...
12
votes
1answer
91 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
121 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
60 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 ...