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

Apex Heap Error
Hi all,
I have an issue in my controller. Basically, I have a VF page that displays data, and to filter the data I have two checkbox value>0, and remaining>0. Now, when I click on remaining>0 and click on the button, the code runs well and displays me the correct output. The number of data after this filter is less than thousand. But on the other hand, when i click value>0, and click the button, it throws me an error saying Apex Heap Size too large. In this case, the total number of data it should output is almost 20K. I think it is showing the error because of too many data in it.
Please let me know if you have suggestion on resolving this issue.
Thanks!
Justin:
APEX heap size is limited so if you are retrieving many records - 20K - then you will easily exhaust the limit
The solution is to return paged results akin to the way a SFDC View works -- you note that Views will never return more than 200 rows for display and you use Next | Previous to page through the query results
The solution is well-documented in the VF Developer's Guide under List Controllers, the key is the Database.QueryLocator but you can start here: http://blog.jeffdouglas.com/2009/07/14/visualforce-page-with-pagination/
First of all don't forget the getting heap size error only occured for collections. So why don't you add a filter to your list/set or map whatever you used.