🧪 Experimental KB — Official knowledge hub: community.kaptio.com

Apex Heap Size Error When Adding Services or Promotions to Bookings

Users encounter an 'Apex heap size too large' error when attempting to add services or promotions to a booking. The error occurs during pricing calculations and prevents the booking workflow from comp

heap-size promotions governor-limits performance KtApiPromo pricing

Problem

Users encounter an ‘Apex heap size too large’ error when attempting to add services or promotions to a booking. The error occurs during pricing calculations and prevents the booking workflow from completing.

What We Found

The error originated in the KaptioTravel.KtApiPromo.queryPromotions class exceeding Salesforce’s synchronous heap size limit of 6MB. Investigation revealed the org had 746 active promotions, with 650 assigned to combinability groups, and 51 price categories configured on the Group Promotion service. The combination of high promotion count and complex price category configuration caused excessive memory consumption during promotion queries.

Solution

  1. Run this SOQL query to check active promotion count: SELECT COUNT(Id) FROM KaptioTravel__Promotion__c WHERE KaptioTravel__Active__c = true
  2. If count exceeds 500-700, identify promotions that apply to past sales seasons or expired date ranges
  3. Deactivate older promotions that are no longer needed by setting KaptioTravel__Active__c = false
  4. Review promotions with combinability groups - these add additional processing overhead
  5. Consider reducing the number of price categories on services if feasible
  6. Test the booking workflow after deactivating promotions to confirm resolution

Notes

  • Salesforce synchronous heap size limit is 6MB - this cannot be increased
  • The error stack trace will reference Class.KaptioTravel.KtApiPromo.queryPromotions when promotions are the cause
  • Promotions in combinability groups consume more memory than standalone promotions
  • Services with many price categories multiply the memory impact during pricing calculations

Warnings

⚠️ Do not delete promotions - deactivate them instead to preserve historical booking data ⚠️ Coordinate with the customer’s pricing/marketing team before deactivating promotions


Source: KHELP-12344

Was this article helpful?