Skip to main content
Hi All,

I have created an APEX REST service to insert few records in custom object and few attachments. The service works fine for multiple attachments of size ~60KB. However, when attachments of size ~2MB is sent, we get an error 'Apex heap size too large'. I have a requirement where multiple attachments of size ~3MB should be inserted using REST API. Please help.
3 respostas
  1. 19 de abr. de 2017, 13:26
    I am sure you must be aware of Heap Size limit of 6 MB for Synchronous and 12 MB for Asynchronous ..

    So can you modify your code to only ask 1 attachment at a time.

    The attachment could be either 60 KB or 3 MB.

    In this way you will never hit Heap Memory limit...

    If for some reason , you cannot modify your code to limit the transaction to 1 attachment, ask the sender ( developer of the other system with which SFDC is integrating) to send only 1 attachment per request from SFDC.

    This is the only solution I can think of at this time.