I am passing some data as string from my Visualforce page to apex via apex function, I store that data by in attachment body through apex code. I came to know from response to my previous question that heap size limit is 6MB, so I won't be able to store more data than that.

In my case I have to store one message at a time and then append to same file when next message arrives, apex function will be called on every message, after appending message apex function would return null. So I am not trying to pass more than a few KBs at a time.

Would I be able to utilize all storage limit by following this saving data in a step by step approach? If yes, then limit would be 25 MB?

Also, 25 MB is limit for one attachment or all attachments combined?

1 Answer 1


First to clear your concepts :

Heap size, in your case, will be considered when you pass more than 6MB of string data from UI to backend in one transaction. (FYI : Each transaction from UI to server will be treated as fresh transaction and your heap limit will get reset with each call)

Also if you want to store one message at a time, then why to fire BackEnd call everytime, just have a list defined in your Javascript and store everything there and at the end fire a sforce Connection to create your attachment on the client side only. By this way you can create an attachment of 25 MB.

25 MB is limit for one attachment or all attachments combined?

25MB is the limit for each attachment.

  • Total size available for all attachments can be 2GB, right?
    – Badar
    Commented Dec 7, 2020 at 6:27
  • No, that's a different limit. That is Salesforce Lightning attachment limit. Commented Dec 7, 2020 at 6:30
  • Since I am using Salesforce lightning, so I am assuming that I will be able to store attachments upto 2Gb, where each attachment can be max 25MB.
    – Badar
    Commented Dec 7, 2020 at 6:32
  • No, you are using VFPages here. Commented Dec 7, 2020 at 6:32
  • I see, since the files are actually being stored in Salesforce lightning, storage limit would stay the same, no? In case they are different, once I have stored an attachment 25MB using VF page code, could you please tell me what will be space available If I need to store more files?
    – Badar
    Commented Dec 7, 2020 at 6:37

You must log in to answer this question.

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