Questions tagged [cpulimit]

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

Filter by
Sorted by
Tagged with
2
votes
1answer
72 views

Apex CPU Limit Loading Large Data

I am encountering and error while doing a data load. here is my code when dataloading. is there anything that needs to be optimize in here so far? public class depToAccount { public static void ...
2
votes
2answers
252 views

Apex Sleep: what is CPU penalty

As we know (as of V46), there is no apex sleep method. Various workarounds have been proposed such as doing a callout to a service with platform support for sleep but this makes unit testing ...
2
votes
2answers
64 views

How to know if Managed Package available in app exchange is Certified from Salesforce or not

We are considering installing the managed package in our org. We know that if Package is certified then different limits are given by Salesforce to the Package outside our ORG CPU limit. Is there any ...
9
votes
1answer
379 views

Is anybody experiencing Apex CPU timeout exceptions after Summer 19 release upgrade

Just wanted to check if anybody else is experiencing this. Last friday everything was running perfectly. On saturday our instance was upgraded to Summer 19, and on monday we started seeing Apex CPU ...
1
vote
2answers
168 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
65 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
35 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
113 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
152 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
205 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
109 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
106 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
88 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
378 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
306 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
796 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
34 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
358 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
200 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
345 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
246 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
195 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
388 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
396 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
63 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
55 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
55 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
126 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
186 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
904 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
233 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
347 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
507 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
43 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
129 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
288 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
260 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
138 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
619 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
321 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
47 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
180 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 ...
27
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 ...