After creating a custom file-uploader lightning component we had the following problem :

  • The amount of data to be passed from lightning controller to server-side controller (apex) was limited (around 3 MB).


  • We have implemented the component on a sandbox org.
  • To solve the problem , we pass the data in chunks which are smaller than 3 MB and we use the 6 MB heap memory from apex to append the chunks together.

  • The approached solution works fine on the sandbox, as long the total size of all chunks is smaller than 6 MB (Because of the heap's limit => 6MB).

Deployment to production org :

  • After we deployed the component to the production org , we tested the component and we got a strange result.
  • We got a System.LimitsException (Which of course can't be caught). In the following image is the exception :

enter image description here

What we cant understand is that the file is only 3.74MB and not (~ 8MB). Also I don't think that the problem is in the performance of the code (or the usage of memory) because we used the exact same component on the sandbox and uploaded the exact file and it worked just fine.

Is there any difference between the heap consumption on production org and sandbox? if the answer is no , what can cause such a problem?

1 Answer 1


The amount of heap used is the same in all types of orgs; one byte of data is still one byte of data. Once you go over 6MB in a single transaction, Salesforce may choose to terminate the process (or not).

More heavily loaded instances are more likely to more strictly enforce the limits to ensure all users get fair access to resources. This may be your problem. Production orgs tend to perform heap checks more frequently and/or be more aggressive about terminating processes because of governor limits.

Without seeing your code, it'd be hard to tell what's going on, but some optimization should be possible to keep yourself roughly below 6MB of heap for up to about 5.9MB of data if you're careful.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .