Search code examples
salesforceapex-codevisualforce

Heap size related error


how to increase heap size? or how to overcome the problem related to heap size. I am facing error related to heap size. my error is:

Apex heap size too large: 9264402 Error is in expression '{!method}' in component in page page1

I have used transient keyword with my variable but it is not working for me. I am showing table on the page and if i use transient keyword, my table content is not being shown on my page.

So, please give me reply if you know how to solve this problem. thank you.


Solution

  • Marking a member variable as transient means you don't need to maintain the value of the variable across HTTP requests and so it never gets sent to the page as part of the view state.

    From the limited information available I can only suggest two things (posting code would be helpful here):

    1. You're being inefficient with data in memory somewhere, you might be able to reduce usage by clearing collections (or setting them to null) when they're no longer needed.
    2. You're simply loading too much data from the database. It would seem like this is a good place to leverage the new SOQL OFFSET statement and implement some sort of pagination so that you're not displaying all of the data at once (or even just limit your results with LIMIT X on your query).