Sub topic 9
Limits and Keeping the Org Active
This chapter assumes you can log in to your Developer Edition org and open Setup, and that you have run a basic command in a terminal. It covers the main limits of the org and the habits that stop Salesforce from deleting it.
Why a free org has limits
A Developer Edition org is a free environment for learning and building. Salesforce caps its resources so that it stays useful for development but not for running a business. Limits fall into two groups:
- Org limits, such as storage, user licenses and API requests per day.
- Per-transaction limits, called governor limits, which apply to Apex code in every edition.
Org limits to know
The figures below are typical for Developer Edition at the time of writing. Salesforce changes them, so confirm your own numbers in the org.
| Resource | Typical Developer Edition value | Where to check |
|---|---|---|
| Data storage | 5 MB | Setup, Storage Usage |
| File storage | 20 MB | Setup, Storage Usage |
| Full user licenses | 2 | Setup, Company Information |
| API requests | 15,000 per 24 hours | CLI or Setup, System Overview |
Data storage is the limit people hit first. Salesforce counts most records as roughly 2 KB each, so 5 MB holds about 2,500 records. Loading a large sample dataset can fill the org quickly.
Reading your limits from the CLI
The Salesforce CLI can report how much of each limit you have used. This uses the alias from the earlier CLI chapter.
sf org list limits --target-org my-dev-orgThe output lists each limit with its current remaining value and its maximum. Look for DailyApiRequests and DataStorageMB. If the remaining value is near zero, requests or saves start failing with errors that mention a limit.
Governor limits in Apex
Governor limits cap what one Apex transaction can do. They protect the shared servers that many orgs use. Common synchronous limits are:
- 100 SOQL queries per transaction.
- 150 DML statements (inserts, updates, deletes) per transaction.
- 10 seconds of CPU time.
You can see them from code with the Limits class. Run this as anonymous Apex:
System.debug('Queries used: ' + Limits.getQueries() + ' of ' + Limits.getLimitQueries());
System.debug('DML used: ' + Limits.getDmlStatements() + ' of ' + Limits.getLimitDmlStatements());The most common mistake is running a query or DML statement inside a loop. Each pass uses up part of the quota, and the transaction fails once it passes the limit. Query once outside the loop and work with the results.
Keeping the org from going inactive
Salesforce deletes Developer Edition orgs that nobody logs in to for a long period. The period has been about six months, but check the current policy in the Salesforce Developer Edition documentation. Salesforce sends warning emails to the org's admin address before it deletes the org. A deleted org cannot be recovered, and its username becomes free again.
To keep the org active:
- Log in at least once every few months. Logging in through the browser or the CLI both count as activity.
- Make sure the email address on your user record is one you still read, so you see the warnings.
- Keep a copy of anything you built in source control, such as metadata retrieved with the CLI.
- Put a recurring reminder in your calendar.
Common errors
STORAGE_LIMIT_EXCEEDED: data storage is full. Delete test records and empty the Recycle Bin, because deleted records still count until the bin is emptied.REQUEST_LIMIT_EXCEEDED: you used all API requests in 24 hours. A script or integration that polls too often is the usual cause. Wait for the window to roll over and reduce how often it runs.Too many SOQL queries: 101: a governor limit error. Move the query out of the loop.
Exercise
A script you wrote calls the org's API every few seconds. After some hours it fails with REQUESTLIMITEXCEEDED. Which command shows how many daily API requests remain, and what should you change in the script?
Show answer
Run sf org list limits --target-org my-dev-org and read the DailyApiRequests line. Reduce how often the script calls the API, for example by batching requests or polling less often, so it stays under the 24-hour cap.