Conga Product Documentation

Welcome to the new doc site. Some of your old bookmarks will no longer work. Please use the search bar to find your desired topic.

Visualforce Remoting Exception: Apex heap size too large

Salesforce enforces an Apex Heap Size Limit of 6 MB for synchronous transactions and 12 MB for asynchronous transactions.

The Apex heap size too large exception occurs when too much data is being stored in memory during processing. The limit depends on the type of execution (for example, synchronous or asynchronous calls).

Sample Business Use Cases

When the constraint rule maintenance batch job is executed from the Maintenance tab, it runs erroneously. Especially for constraint rules with Product Field Set in Product Scope in constrain rule condition and criteria, a lot of memory is consumed to create Product Constraint View records. Eventually the batch crosses Salesforce governor limit of 12 MB memory usage per asynchronous transaction and skips creating views for some rules.

The following exception occurs: Apex heap size too large: 13808228.

The Apex governor limits for heap size are as follows:

Total Heap Size

Synchronous Limit

6 MB

Asynchronous Limit

12 MB

Email Services

32 MB

Best Practices
  • Do not use class-level variables to store a large amount of data.
  • Utilize SOQL For loops to iterate and process data from large queries.
  • Construct methods and loops that allow variables to go out of scope as soon as they are no longer needed.
  • Reduce the limits to the SOQLs and use transient keyword.