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:
Integer queryLimitRows = Limits.getLimitQueryRows();
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.
Limits Methods:
The following are methods for Limits. All methods are static.
System.debug('Limits.getAggregateQueries - '+ Limits.getAggregateQueries()); System.debug('Limits.getLimitAggregateQueries - '+ Limits.getLimitAggregateQueries()); System.debug('Limits.getCallouts - '+ Limits.getCallouts()); System.debug('Limits.getLimitCallouts - '+ Limits.getLimitCallouts()); System.debug('Limits.getCpuTime - '+ Limits.getCpuTime()); System.debug('Limits.getLimitCpuTime - '+ Limits.getLimitCpuTime()); System.debug('Limits.getDMLRows - '+ Limits.getDMLRows()); System.debug('Limits.getLimitDMLRows - '+ Limits.getLimitDMLRows()); System.debug('Limits.getDMLStatements - '+ Limits.getDMLStatements()); System.debug('Limits.getLimitDMLStatements - '+ Limits.getLimitDMLStatements()); System.debug('Limits.getEmailInvocations - '+ Limits.getEmailInvocations()); System.debug('Limits.getLimitEmailInvocations - '+ Limits.getLimitEmailInvocations()); System.debug('Limits.getFutureCalls - '+ Limits.getFutureCalls()); System.debug('Limits.getLimitFutureCalls - '+ Limits.getLimitFutureCalls()); System.debug('Limits.getHeapSize - '+ Limits.getHeapSize()); System.debug('Limits.getLimitHeapSize - '+ Limits.getLimitHeapSize()); System.debug('Limits.getMobilePushApexCalls - '+ Limits.getMobilePushApexCalls()); System.debug('Limits.getLimitMobilePushApexCalls - '+ Limits.getLimitMobilePushApexCalls()); System.debug('Limits.getQueries - '+ Limits.getQueries()); System.debug('Limits.getLimitQueries - '+ Limits.getLimitQueries()); System.debug('Limits.getQueryLocatorRows - '+ Limits.getQueryLocatorRows()); System.debug('Limits.getLimitQueryLocatorRows - '+ Limits.getLimitQueryLocatorRows()); System.debug('Limits.getQueryRows - '+ Limits.getQueryRows()); System.debug('Limits.getLimitQueryRows - '+ Limits.getLimitQueryRows()); System.debug('Limits.getQueueableJobs - '+ Limits.getQueueableJobs()); System.debug('Limits.getLimitQueueableJobs - '+ Limits.getLimitQueueableJobs()); System.debug('Limits.getSoslQueries - '+ Limits.getSoslQueries()); System.debug('Limits.getLimitSoslQueries - '+ Limits.getLimitSoslQueries());