Limits Class

Contains methods that return limit information for specific resources.

System

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.

  • 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.

  • getApexCursors()

    Gets the number of Apex cursors that are created.

  • getLimitApexCursors()

    Gets the maximum number of Apex cursors that can be created per transaction.

  • getApexCursorRows()

    Gets the number of rows returned by an Apex cursor.

  • getLimitApexCursorRows()

    Gets the maximum number of rows that can be returned by an Apex cursor.

  • getApexPaginationCursors()

    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.

  • getApexPaginationCursorRows()

    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.

  • getFetchCallsOnApexCursor()

    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.

  • 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.

  • getDataCloudCursors()

    Returns the number of cursors created so far in this transaction.

  • getLimitDataCloudCursors()

    Returns the maximum number of Data 360 cursors createable in this transaction. Defaults to 50.

  • getDataCloudCursorRows()

    Returns the number of rows charged so far in this transaction.

  • getLimitDataCloudCursorRows()

    Returns the maximum total rows across Data 360 cursors this transaction. Defaults to 50 million.

  • getDataCloudFlexCredits()

    Reserved for future use.

  • getLimitDataCloudFlexCredits()

    Reserved for future use.

  • 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.

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