You need to sign in to do that
Don't have an account?

Apex heap size too large in VF page
Hi All
I am getting an error called "Apex heap size too large in VF page" while uploading a file via <input type="file"> component in visualforce page. I suspect it's an error from developer's side. Whenever I am uploading a file than 4MB, the error is coming.
Please help on this to get off the error. My file upload is working fine if the file size is less than 4MB
Here is my code:
I am getting an error called "Apex heap size too large in VF page" while uploading a file via <input type="file"> component in visualforce page. I suspect it's an error from developer's side. Whenever I am uploading a file than 4MB, the error is coming.
Please help on this to get off the error. My file upload is working fine if the file size is less than 4MB
Here is my code:
<input type="file" id="fileupload1" onchange="submitImages(this.id);" /> <apex:actionFunction name="submitFilename" rerender="thisform" action="{!AddAttachments}" > <apex:param name="fileBody" value="txt"></apex:param> <apex:param name="filename" value="na"></apex:param> <apex:param name="thisCompID" value=""></apex:param> </apex:actionFunction> function submitImages(thisCompID) { var file = document.getElementById(thisCompID).files[0]; console.log(file); if (file != undefined) { var attachmentName = file.name; var fileReader = new FileReader(); fileReader.onloadend = function(e) { var attachment = window.btoa(this.result); //Base 64 encode the file before sending it positionIndex = 0; fileSize = attachment.length; console.log(attachment); submitFilename(attachment, attachmentName,thisCompID); } fileReader.onerror = function(e) { alert( "There was an error reading the file. Please try again." ); } fileReader.onabort = function(e) { alert( "There was an error reading the file. Please try again." ); } fileReader.readAsBinaryString(file); //Read the body of the file } else { alert("You must choose a file before trying to upload it"); } }
https://hub.appirio.com/tech-blog/upload-a-file-as-large-as-2gb-in-salesforce-using-a-visualforce-page
https://kevansfdc.blogspot.com/2017/05/upload-attachment-to-salesforce-without.html
https://salesforce.stackexchange.com/questions/7800/loading-files-greater-than-5m-using-vf-page
https://www.formassembly.com/blog/tip-send-large-files-to-salesforce/
http://www.techdexterous.com/2017/03/how-upload-large-file-in-salesforce.html
Sorry for this issue you are facing.
May I suggest you please refer to below link which might help you further with the above issue where it has a lot of useful information around heap management in this post.
- https://blog.jeffdouglas.com/2010/08/16/managing-the-heap-in-salesforce-com/
Hope this helps.Thanks,
Nagendra