This article explains the Salesforce Visualforce error "Collection size X exceeds the maximum size of 1,000," including when the error is displayed and why it occurs.
This article answers the question: why does the "Collection size exceeds the maximum size of 1,000" error appear in Salesforce, and how can it be resolved?
Collections in Apex are data structures used to store and manage multiple records or values in a single variable. Common types include Lists (an ordered collection), Sets (a unique unordered collection), and Maps (key-value pairs). While Apex itself does not impose a strict limit on collection size, certain contexts like Visualforce pages restrict collections to a maximum of 1,000 items when rendering data.
Governor limits are system-enforced restrictions in Salesforce designed to ensure efficient use of shared resources in a multi-tenant environment. These limits control aspects like CPU time, memory usage, and database operations. While Apex can handle large datasets, there are limits such as the number of records returned in certain operations (for example, Visualforce rendering limits of 1,000 items per collection), which can trigger errors if exceeded.
This error message is displayed when the collection limit of a Visualforce page is exceeded. A collection can contain up to 1,000 items. This limit applies to the Visualforce page itself, and the same limit applies to repetitive output components, including <apex:repeat>, <apex:dataList>, and <apex:pageBlockTable>. A similar description of the limitation is found in the reference documentation for each component.
For Apex classes, this limit was removed starting in Spring '10 (API 18.0). For API versions prior to that, a limit of 1,000 items was applied to Apex classes as well.
000385328

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.