HI Satya, On a general note, > Don't use class level variables to store large amounts of data. > Use maps instead of lists when working with large amounts of data. > Use the Limits methods to check your code's heap size and avoid exceeding the limit.
See https://developer.salesforce.com/forums/ForumsMain?id=9062I000000DHPC
If you are specifically encountering a heap size error when uploading attachments, you can: > Chunk the data being uploaded into smaller pieces. > Use Apex Aura methods to upload the file in chunks.
On a general note,
> Don't use class level variables to store large amounts of data.
> Use maps instead of lists when working with large amounts of data.
> Use the Limits methods to check your code's heap size and avoid exceeding the limit.
See https://developer.salesforce.com/forums/ForumsMain?id=9062I000000DHPC
If you are specifically encountering a heap size error when uploading attachments, you can:
> Chunk the data being uploaded into smaller pieces.
> Use Apex Aura methods to upload the file in chunks.
Recommend reviewing
https://help.salesforce.com/s/articleView?id=000395030&type=1
https://akiroha27.medium.com/overcoming-apexs-12-mb-heap-size-limit-249c2f4c2bb6
https://stackoverflow.com/questions/75226374/how-to-upload-a-large-file-6mb-to-salesforce-through-a-lightning-component-us
If this information helps, please mark the answer as best. Thank you