You need to sign in to do that
Don't have an account?
Trying to Bring Heap Size Down
Hello. I was wondering if anyone could give me some guidance.
I am having issues with the heap size of a certain VF page. Specifically, this is being caused by an IF statement that pulls values from a large list.
Just as a side note...I initially was doing an aggregatedresult COUNT on the below, but due to other SOQL lists on the page, I was beginning to run into 50K limit issues. Therefore, I thought I would just do an IF statement on whether a record met a few conditions. If it did, I would just increase a "Count" variable by 1.
Well, this works...but I am getting dangerously close to the heap size limit.
My page simply displays static data - so there is no need to keep any of the variables/lists in memory after the page renders. Given that, I was thinking that I could bring the heap size down dramatically...but that is where I am having issues.
Thanks in advance.
// This is creating a list from a group of over 300,000 records // The "listA" that gets created below totals around 15,000 records listA = [SELECT id, Duration__c, Location__c, CustCondition__c, HappyCust__c, JoinedDate__c FROM myObject__c WHERE JoinedDate__c=TODAY OR HappyCust__c=false]; // Now I want to count the number of occurrences for records that meet a particular condition Count = 0; // resetting the counter value for (Integer a = 0; a < listA.size(); a++) {
// The below IF statement is what is causing the huge jump in heap size. I was wondering how to fix it
if(listA[a].JoinedDate__c==system.today() && listA[a].Location__c=='NE' && listA[a].Duration__c>=60) { Count = Count + 1; // increasing the counter by one } } listA = null; // I thought nulling out the big list would do the trick - but the heap is still huge
Make sue you give most of the fiekds that will be there for a record
Try indexing by putting unique fiekds
Try to use LIMITs
Does this do the trick?