Limit Class In Salesforce!
LIMIT class contains methods that return limit information for specific resources.
The Limits methods return the specific limit for the particular governor, such as the number of calls of a method or the amount of heap size remaining.
Because Apex runs in a multitenant environment, the Apex runtime engine strictly enforces a number of limits to ensure that runaway Apex doesn’t monopolize shared resources.
None of the Limits methods require an argument.
The format of the limits methods is as follows:
myDMLLimit = Limits.getDMLStatements();
There are two versions of every method: the first returns the amount of the resource that has been used while the second version contains the word limit and returns the total amount of the resource that is available.
See Execution Governors and Limits.
Limits Methods
The following are methods for Limits. All methods are static.
getAggregateQueries()
Returns the number of aggregate queries that have been processed with any SOQL query statement.
getLimitAggregateQueries()
Returns the total number of aggregate queries that can be processed with SOQL query statements.
getAsyncCalls()
Reserved for future use.
getLimitAsyncCalls()
Reserved for future use.
getCallouts()
Returns the number of Web service statements that have been processed.
getChildRelationshipsDescribes()
Deprecated. Returns the number of child relationship objects that have been returned.
getLimitCallouts()
Returns the total number of Web service statements that can be processed.
getCpuTime()
Returns the CPU time (in milliseconds) that has been used in the current transaction.
getLimitCpuTime()
Returns the maximum CPU time (in milliseconds) that can be used in a transaction.
getDMLRows()
Returns the number of records that have been processed with any statement that counts against DML limits, such as DML statements, the Database.emptyRecycleBin method, and other methods.
getLimitDMLRows()
Returns the total number of records that can be processed with any statement that counts against DML limits, such as DML statements, the database.EmptyRecycleBin method, and other methods.
getDMLStatements()
Returns the number of DML statements (such as insert, update or the database.EmptyRecycleBin method) that have been called.
getLimitDMLStatements()
Returns the total number of DML statements or the database.EmptyRecycleBin methods that can be called.
getEmailInvocations()
Returns the number of email invocations (such as sendEmail) that have been called.
getLimitEmailInvocations()
Returns the total number of email invocation (such as sendEmail) that can be called.
getFindSimilarCalls()
Deprecated. Returns the same value as getSoslQueries. The number of findSimilar methods is no longer a separate limit, but is tracked as the number of SOSL queries issued.
getLimitFindSimilarCalls()
Deprecated. Returns the same value as getLimitSoslQueries. The number of findSimilar methods is no longer a separate limit, but is tracked as the number of SOSL queries issued.
getFutureCalls()
Returns the number of methods with the future annotation that have been executed (not necessarily completed).
getLimitFutureCalls()
Returns the total number of methods with the future annotation that can be executed (not necessarily completed).
getHeapSize()
Returns the approximate amount of memory (in bytes) that has been used for the heap.
getLimitHeapSize()
Returns the total amount of memory (in bytes) that can be used for the heap.
getMobilePushApexCalls()
Returns the number of Apex calls that have been used by mobile push notifications during the current metering interval.
getLimitMobilePushApexCalls()
Returns the total number of Apex calls that are allowed per transaction for mobile push notifications.
getPublishImmediateDML()
Returns the number of EventBus.publish calls that have been made for platform events configured to publish immediately.
getLimitPublishImmediateDML()
Returns the total number of EventBus.publish statements that can be called for platform events configured to publish immediately.
getQueries()
Returns the number of SOQL queries that have been issued.
getLimitQueries()
Returns the total number of SOQL queries that can be issued.
getQueryLocatorRows()
Returns the number of records that have been returned by the Database.getQueryLocator method.
getLimitQueryLocatorRows()
Returns the total number of records that can be returned by the Database.getQueryLocator method.
getQueryRows()
Returns the number of records that have been returned by issuing SOQL queries.
getLimitQueryRows()
Returns the total number of records that can be returned by issuing SOQL queries.
getQueueableJobs()
Returns the number of queueable jobs that have been added to the queue per transaction. A queueable job corresponds to a class that implements the Queueable interface.
getLimitQueueableJobs()
Returns the maximum number of queueable jobs that can be added to the queue per transaction. A queueable job corresponds to a class that implements the Queueable interface.
getRunAs()
Deprecated. Returns the same value as getDMLStatements.
getLimitRunAs()
Deprecated. Returns the same value as getLimitDMLStatements.
getSavepointRollbacks()
Deprecated. Returns the same value as getDMLStatements.
getLimitSavepointRollbacks()
Deprecated. Returns the same value as getLimitDMLStatements.
getSavepoints()
Deprecated. Returns the same value as getDMLStatements.
getLimitSavepoints()
Deprecated. Returns the same value as getLimitDMLStatements.
getSoslQueries()
Returns the number of SOSL queries that have been issued.
getLimitSoslQueries()
Returns the total number of SOSL queries that can be issued.
Follow Us