Limits Methods

Because Apex runs in a multitenant environment, the Apex runtime engine strictly enforces a number of limits to ensure that runaway scripts do not monopolize shared resources.

The Limits methods return the specific limit for the context in which they are being executed, that is, from a trigger, a Web service method, and so on.

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 in the current context, while the second version contains the word limit and returns the total amount of the resource that is available for that context.

See Understanding Execution Governors and Limits.

Name Return Type Description
getAggregateQueries Integer Returns the number of aggregate queries that have been processed with any SOQL query statement in the current context.
getLimitAggregateQueries Integer Returns the total number of aggregate queries that can be processed with SOQL query statements in the current context.
getCallouts Integer Returns the number of Web service statements that have been processed in the current context.
getLimitCallouts Integer Returns the total number of Web service statements that can be processed in the current context.
getChildRelationshipsDescribes Integer Returns the number of child relationship objects that have been returned in the current context.
getLimitChildRelationshipsDescribes Integer Returns the total number of child relationship objects that can be returned in the current context.
getCpuTime Integer Returns the CPU time (in milliseconds) accumulated on the Salesforce.com servers in the current transaction.
getLimitCpuTime   Returns the total CPU time (in milliseconds) accumulated on the Salesforce.com servers in the current transaction.
getDMLRows Integer Returns the number of records that have been processed with any DML statement (insertions, deletions) or the database.EmptyRecycleBin method in the current context.
getLimitDMLRows Integer Returns the total number of records that can be processed with any DML statement or the database.EmptyRecycleBin method in the current context.
getDMLStatements Integer Returns the number of DML statements (such as insert, update or the database.EmptyRecycleBin method) that have been called in the current context.
getLimitDMLStatements Integer Returns the total number of DML statements or the database.EmptyRecycleBin methods that can be called in the current context.
getEmailInvocations Integer Returns the number of email invocations (such as sendEmail) that have been called in the current context.
getLimitEmailInvocations Integer Returns the total number of email invocation (such as sendEmail) that can be called in the current context.
getFieldsDescribes Integer Returns the number of field describe calls that have been made in the current context.
getLimitFieldsDescribes Integer Returns the total number of field describe calls that can be made in the current context.
getFindSimilarCalls Integer Returns the number of findSimilar methods that have been executed in the current context.
getLimitFindSimilarCalls Integer Returns the total number of findSimilar methods that can be executed in the current context.
getFutureCalls Integer Returns the number of methods with the future annotation that have been executed (not necessarily completed) in the current context.
getLimitFutureCalls Integer Returns the total number of methods with the future annotation that can be executed (not necessarily completed) in the current context.
getHeapSize Integer Returns the approximate amount of memory (in bytes) that has been used for the heap in the current context.
getLimitHeapSize Integer Returns the total amount of memory (in bytes) that can be used for the heap in the current context.
getQueries Integer Returns the number of SOQL queries that have been issued in the current context.
getLimitQueries Integer Returns the total number of SOQL queries that can be issued in the current context.
getPicklistDescribes Integer Returns the number of PicklistEntry objects that have been returned in the current context.
getLimitPicklistDescribes Integer Returns the total number of PicklistEntry objects that can be returned in the current context.
getQueryLocatorRows Integer Returns the number of records that have been returned by the Database.getQueryLocator method in the current context.
getLimitQueryLocatorRows Integer Returns the total number of records that have been returned by the Database.getQueryLocator method in the current context.
getQueryRows Integer Returns the number of records that have been returned by issuing SOQL queries in the current context.
getLimitQueryRows Integer Returns the total number of records that can be returned by issuing SOQL queries in the current context.
getRecordTypesDescribes Integer Returns the number of RecordTypeInfo objects that have been returned in the current context.
getLimitRecordTypesDescribes Integer Returns the total number of RecordTypeInfo objects that can be returned in the current context.
getRunAs Integer Returns the total number of runAs methods that have been executed in the current context.
getLimitRunAs Integer Returns the total number of runAs methods that can execute in the current context.
getSavepointRollbacks Integer Returns the number of rollback statements that have been issued in the current context.
getLimitSavepointRollbacks Integer Returns the total number of rollback statements that can be returned in the current context.
getSavepoints Integer Returns the number of Savepoint statements that have been issued in the current context.
getLimitSavepoints Integer Returns the total number of Savepoint statements that can be issued in the current context.
getScriptStatements Integer Returns the number of statements that have executed in the current context.
getLimitScriptStatements Integer Returns the total number of statements that can execute in the current context.
getSoslQueries Integer Returns the number of SOSL queries that have been issued in the current context.
getLimitSoslQueries Integer Returns the total number of SOSL queries that can be issued in the current context.
© Copyright 2000-2009 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.