Limits 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:
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.
The following are methods for Limits. All methods are static.
-
Returns the number of aggregate queries that have been processed with any SOQL query statement.
-
Returns the total number of aggregate queries that can be processed with SOQL query statements.
-
Gets the number of Apex cursors that are created.
-
Gets the maximum number of Apex cursors that can be created per transaction.
-
Gets the number of rows returned by an Apex cursor.
-
Gets the maximum number of rows that can be returned by an Apex cursor.
-
Gets the number of Apex pagination cursors that are created.
-
getLimitApexPaginationCursors()
Gets the maximum number of Apex pagination cursors that can be created per transaction.
-
Gets the number of rows returned by an Apex pagination cursor.
-
getLimitApexPaginationCursorRows()
Gets the maximum number of rows that can be returned by an Apex pagination cursor.
-
Gets the number of fetch calls on an Apex cursor.
-
getLimitFetchCallsOnApexCursor()
Gets the maximum number of fetch calls that can be made on an Apex cursor.
-
Reserved for future use.
-
Reserved for future use.
-
Returns the number of Web service statements that have been processed.
-
getChildRelationshipsDescribes()
Deprecated. Returns the number of child relationship objects that have been returned.
-
Returns the total number of Web service statements that can be processed.
-
Returns the CPU time (in milliseconds) that has been used in the current transaction.
-
Returns the maximum CPU time (in milliseconds) that can be used in a transaction.
-
Returns the number of cursors created so far in this transaction.
-
Returns the maximum number of Data 360 cursors createable in this transaction. Defaults to 50.
-
Returns the number of rows charged so far in this transaction.
-
Returns the maximum total rows across Data 360 cursors this transaction. Defaults to 50 million.
-
Reserved for future use.
-
getLimitDataCloudFlexCredits()
Reserved for future use.
-
Returns the number of records that have been processed with any statement that counts against DML limits, such as DML statements, the
Database.emptyRecycleBinmethod, and other methods. -
Returns the total number of records that can be processed with any statement that counts against DML limits, such as DML statements, the
database.EmptyRecycleBinmethod, and other methods. -
Returns the number of DML statements (such as
insert,updateor thedatabase.EmptyRecycleBinmethod) that have been called. -
Returns the total number of DML statements or the
database.EmptyRecycleBinmethods that can be called. -
Returns the number of email invocations (such as
sendEmail) that have been called. -
Returns the total number of email invocation (such as
sendEmail) that can be called. -
Deprecated. Returns the same value as
getSoslQueries. The number offindSimilarmethods is no longer a separate limit, but is tracked as the number of SOSL queries issued. -
Deprecated. Returns the same value as
getLimitSoslQueries. The number offindSimilarmethods is no longer a separate limit, but is tracked as the number of SOSL queries issued. -
Returns the number of methods with the
futureannotation that have been executed (not necessarily completed). -
Returns the total number of methods with the
futureannotation that can be executed (not necessarily completed). -
Returns the approximate amount of memory (in bytes) that has been used for the heap.
-
Returns the total amount of memory (in bytes) that can be used for the heap.
-
Returns the number of Apex calls that have been used by mobile push notifications during the current metering interval.
-
Returns the total number of Apex calls that are allowed per transaction for mobile push notifications.
-
Returns the number of
EventBus.publishcalls that have been made for platform events configured to publish immediately. -
Returns the total number of
EventBus.publishstatements that can be called for platform events configured to publish immediately. -
Returns the number of SOQL queries that have been issued.
-
Returns the total number of SOQL queries that can be issued.
-
Returns the number of records that have been returned by the
Database.getQueryLocatormethod. -
Returns the total number of records that can be returned by the
Database.getQueryLocatormethod. -
Returns the number of records that have been returned by issuing SOQL queries.
-
Returns the total number of records that can be returned by issuing SOQL queries.
-
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
Queueableinterface. -
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
Queueableinterface. -
Deprecated. Returns the same value as
getDMLStatements. -
Deprecated. Returns the same value as
getLimitDMLStatements. -
Deprecated. Returns the same value as
getDMLStatements. -
Deprecated. Returns the same value as
getLimitDMLStatements. -
Deprecated. Returns the same value as
getDMLStatements. -
Deprecated. Returns the same value as
getLimitDMLStatements. -
Returns the number of SOSL queries that have been issued.
-
Returns the total number of SOSL queries that can be issued.
Returns the number of aggregate queries that have been processed with any SOQL query statement.
public static Integer getAggregateQueries()
Type: Integer
Returns the total number of aggregate queries that can be processed with SOQL query statements.
public static Integer getLimitAggregateQueries()
Type: Integer
Gets the number of Apex cursors that are created.
public static Integer getApexCursors()
Type: Integer
Gets the maximum number of Apex cursors that can be created per transaction.
public static Integer getLimitApexCursors()
Type: Integer
Gets the number of rows returned by an Apex cursor.
public static Integer getApexCursorRows()
Type: Integer
Gets the maximum number of rows that can be returned by an Apex cursor.
public static Integer getLimitApexCursorRows()
Type: Integer
Gets the number of Apex pagination cursors that are created.
public static Integer getApexPaginationCursors()
Type: Integer
Gets the maximum number of Apex pagination cursors that can be created per transaction.
public static Integer getLimitApexPaginationCursors()
Type: Integer
Gets the number of rows returned by an Apex pagination cursor.
public static Integer getApexPaginationCursorRows()
Type: Integer
Gets the maximum number of rows that can be returned by an Apex pagination cursor.
public static Integer getLimitApexPaginationCursorRows()
Type: Integer
Gets the number of fetch calls on an Apex cursor.
public static Integer getFetchCallsOnApexCursor()
Type: Integer
Gets the maximum number of fetch calls that can be made on an Apex cursor.
public static Integer getLimitFetchCallsOnApexCursor()
Type: Integer
Reserved for future use.
public static Integer getAsyncCalls()
Type: Integer
Reserved for future use.
public static Integer getLimitAsyncCalls()
Type: Integer
Returns the number of Web service statements that have been processed.
public static Integer getCallouts()
Type: Integer
Deprecated. Returns the number of child relationship objects that have been returned.
public static Integer getChildRelationshipsDescribes()
Type: Integer
Because describe limits are no longer enforced in any API version, this method is no longer available. In API version 30.0 and earlier, this method is available but is deprecated.
Returns the total number of Web service statements that can be processed.
public static Integer getLimitCallouts()
Type: Integer
Returns the CPU time (in milliseconds) that has been used in the current transaction.
public static Integer getCpuTime()
Type: Integer
Returns the maximum CPU time (in milliseconds) that can be used in a transaction.
public static Integer getLimitCpuTime()
Type: Integer
Returns the number of cursors created so far in this transaction.
public static Integer getDataCloudCursors()
Type: Integer
Returns the maximum number of Data 360 cursors createable in this transaction. Defaults to 50.
public static Integer getLimitDataCloudCursors()
Type: Integer
Returns the number of rows charged so far in this transaction.
public static Integer getDataCloudCursorRows()
Type: Integer
Returns the maximum total rows across Data 360 cursors this transaction. Defaults to 50 million.
public static Integer getLimitDataCloudCursorRows()
Type: Integer
Reserved for future use.
public static Integer getDataCloudFlexCredits()
Type: Integer
Reserved for future use.
public static Integer getLimitDataCloudFlexCredits()
Type: Integer
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.
public static Integer getDMLRows()
Type: Integer
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.
public static Integer getLimitDMLRows()
Type: Integer
Returns the number of DML statements (such as insert, update or the database.EmptyRecycleBin method) that have been called.
public static Integer getDMLStatements()
Type: Integer
Returns the total number of DML statements or the database.EmptyRecycleBin methods that can be called.
public static Integer getLimitDMLStatements()
Type: Integer
Returns the number of email invocations (such as sendEmail) that have been called.
public static Integer getEmailInvocations()
Type: Integer
Returns the total number of email invocation (such as sendEmail) that can be called.
public static Integer getLimitEmailInvocations()
Type: Integer
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.
public static Integer getFindSimilarCalls()
Type: Integer
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.
public static Integer getLimitFindSimilarCalls()
Type: Integer
Returns the number of methods with the future annotation that have been executed (not necessarily completed).
public static Integer getFutureCalls()
Type: Integer
Returns the total number of methods with the future annotation that can be executed (not necessarily completed).
public static Integer getLimitFutureCalls()
Type: Integer
Returns the approximate amount of memory (in bytes) that has been used for the heap.
public static Integer getHeapSize()
Type: Integer
Returns the total amount of memory (in bytes) that can be used for the heap.
public static Integer getLimitHeapSize()
Type: Integer
Returns the number of Apex calls that have been used by mobile push notifications during the current metering interval.
public static Integer getMobilePushApexCalls()
Type:Integer
Returns the total number of Apex calls that are allowed per transaction for mobile push notifications.
public static Integer getLimitMobilePushApexCalls()
Type:Integer
Returns the number of EventBus.publish calls that have been made for platform events configured to publish immediately.
public static Integer getPublishImmediateDML()
Type: Integer
Returns the total number of EventBus.publish statements that can be called for platform events configured to publish immediately.
public static Integer getLimitPublishImmediateDML()
Type: Integer
Returns the number of SOQL queries that have been issued.
public static Integer getQueries()
Type: Integer
Returns the total number of SOQL queries that can be issued.
public static Integer getLimitQueries()
Type: Integer
Returns the number of records that have been returned by the Database.getQueryLocator method.
public static Integer getQueryLocatorRows()
Type: Integer
Returns the total number of records that can be returned by the Database.getQueryLocator method.
public static Integer getLimitQueryLocatorRows()
Type: Integer
Returns the number of records that have been returned by issuing SOQL queries.
public static Integer getQueryRows()
Type: Integer
Returns the total number of records that can be returned by issuing SOQL queries.
public static Integer getLimitQueryRows()
Type: Integer
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.
public static Integer getQueueableJobs()
Type: Integer
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.
public static Integer getLimitQueueableJobs()
Type: Integer
Deprecated. Returns the same value as getDMLStatements.
public static Integer getRunAs()
Type: Integer
The number of RunAs methods is no longer a separate limit, but is tracked as the number of DML statements issued.
Deprecated. Returns the same value as getLimitDMLStatements.
public static Integer getLimitRunAs()
Type: Integer
The number of RunAs methods is no longer a separate limit, but is tracked as the number of DML statements issued.
Deprecated. Returns the same value as getDMLStatements.
public static Integer getSavepointRollbacks()
Type: Integer
The number of Rollback methods is no longer a separate limit, but is tracked as the number of DML statements issued.
Deprecated. Returns the same value as getLimitDMLStatements.
public static Integer getLimitSavepointRollbacks()
Type: Integer
The number of Rollback methods is no longer a separate limit, but is tracked as the number of DML statements issued.
Deprecated. Returns the same value as getDMLStatements.
public static Integer getSavepoints()
Type: Integer
The number of setSavepoint methods is no longer a separate limit, but is tracked as the number of DML statements issued.
Deprecated. Returns the same value as getLimitDMLStatements.
public static Integer getLimitSavepoints()
Type: Integer
The number of setSavepoint methods is no longer a separate limit, but is tracked as the number of DML statements issued.
Returns the number of SOSL queries that have been issued.
public static Integer getSoslQueries()
Type: Integer
Returns the total number of SOSL queries that can be issued.
public static Integer getLimitSoslQueries()
Type: Integer