Apex heap size too large

  • 1
  • Problem
  • Updated 4 years ago
  • Solved
  • (Edited)
In one of my skuid page for new records i am getting error as:

Apex heap size too large: 9436523

Please can any one tell me why i am getting this error?

Please reply ASAP and tell me of this error.

Thanks.
Arpit
Photo of Arpit

Arpit

  • 1,514 Points 1k badge 2x thumb

Posted 5 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Hello Arpit,

The heap size limit is exceeded when a combination of too much data and metadata is retrieved into Skuid. Here are some possible causes of this issue, and way to resolve:

1 (most likely). You are requesting too many records in one of your Models. If you are working on a Skuid Page for creating new records, make sure that your Models have the "Load model data on page load" property (in the Model "Advanced" properties) turned OFF --- if this is turned on, and your Models do not have any Conditions, then your models will try to load a TON of data, which will kill your page.

2) You are requesting too many Fields in your Models --- usually only happens when you have multiple Models on your page with 100's of fields in each.

3) You have too many Models, and those Models all are requesting Picklist fields that have lots and lots of Picklist values. Try consolidating your Models.

Regards,

Zach
Photo of Arpit

Arpit

  • 1,514 Points 1k badge 2x thumb
Thanks Zach.

It resolved my issue.

Thanks.
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,738 Points 5k badge 2x thumb
We've hit this once or twice and used these hints to fix the issue.

But today we've hit it differently. The page itself renders fine, but the Skuid page builder for the page returns the heap size error. So we can't get at the page to fix it, which is a tad challenging. This is on v4.2.

Photo of Zach McElrath

Zach McElrath, Employee

  • 49,004 Points 20k badge 2x thumb
That's no fun. I'd try modifying your Page XML to remove a Model or some fields in a Model. You can do that by going to the URL:

/apex/skuid__UI?page=PageXMLEdit&id=[YOUR_PAGE_ID]
Photo of Glenn Elliott

Glenn Elliott, Champion

  • 7,738 Points 5k badge 2x thumb
Thanks Zach. Amazingly, I didn't know about that URL, so that's very handy. Looks like the issue was that we had a sizeable chunk of Javascript in the page as inline resources and it seems that removing that out to static resources might take the burden off the Page Builder page. So that's easy enough to manage.
Photo of Bridget Dubas

Bridget Dubas

  • 212 Points 100 badge 2x thumb
Hi Zach, hoping you have a recommendation for me on an Account Detail page.  I have a tab for Opportunities and I am trying to display all Opportunities (open and closed) that have a Ship Date greater than last quarter.  I ran into the same Apex heap size too large error.  The Account I was testing in preview has 700 Opportunities that fit the condition I set.  I realize this is a large data set but even just open Opptys for this particular account would be close to 400.
Is there any way we will be able to provide access to all these records through the Account Detail page?  I appreciate any guidance you have.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,704 Points 20k badge 2x thumb
You can also reduce the number of fields you choose in the model. If you've got 300 fields in the model, then for sure you've be able to resolved the issue by reducing them down to the fields you see on the page.
Photo of Bridget Dubas

Bridget Dubas

  • 212 Points 100 badge 2x thumb
Thanks Pat!  I only had about 15 fields in the model but I took a few out and the error went away.