Skip to main content
added 124 characters in body
Source Link
BarCotter
  • 12.4k
  • 4
  • 38
  • 58

You are querying too many unneeded records and creating Attachments for them which is why you are hitting the heap limit. Try make the 2 changes listed below

1: Restrict your query

Changing the SOQL to have extra where conditions will mean you are querying less records which means less fields that are base64 encoded. The SOQL below is looking at the Account_vod__c fields which will mean you query less records.

[select Name,Id,Signature_vod__c,Signature_Date_vod__c,Account_vod__c 
    from  Call2_vod__c 
    where Signature_Date_vod__c !=Null and Account_vod__c in :existMap.keySet()]

The extra check for Account_vod__c in :existMap.keySet() will stop you querying the records you are not interested in.

2: Change the for loop

Because you do your SOQL and store the results in a it means that ALL records will be on the heap. Try changing your for loop to the format shown below. This will avoid the heap issues are you are not storing all the results to a list:

for (Call2_vod__c call : [select ... from ... where ...]) {
    //
}

Doing number 2 will probably fix your issue but having the SOQL returning so many records is wrong and will cause problems as the number of Call2_vod__c records grow. For example: you will hit another limit if that query returns more than 10,000 records

You are querying too many unneeded records and creating Attachments for them which is why you are hitting the heap limit. Try make the 2 changes listed below

1: Restrict your query

Changing the SOQL to have extra where conditions will mean you are querying less records which means less fields that are base64 encoded. The SOQL below is looking at the Account_vod__c fields which will mean you query less records.

[select Name,Id,Signature_vod__c,Signature_Date_vod__c,Account_vod__c 
    from  Call2_vod__c 
    where Signature_Date_vod__c !=Null and Account_vod__c in :existMap.keySet()]

2: Change the for loop

Because you do your SOQL and store the results in a it means that ALL records will be on the heap. Try changing your for loop to the format shown below. This will avoid the heap issues are you are not storing all the results to a list:

for (Call2_vod__c call : [select ... from ... where ...]) {
    //
}

Doing number 2 will probably fix your issue but having the SOQL returning so many records is wrong and will cause problems as the number of Call2_vod__c records grow. For example: you will hit another limit if that query returns more than 10,000 records

You are querying too many unneeded records and creating Attachments for them which is why you are hitting the heap limit. Try make the 2 changes listed below

1: Restrict your query

Changing the SOQL to have extra where conditions will mean you are querying less records which means less fields that are base64 encoded. The SOQL below is looking at the Account_vod__c fields which will mean you query less records.

[select Name,Id,Signature_vod__c,Signature_Date_vod__c,Account_vod__c 
    from  Call2_vod__c 
    where Signature_Date_vod__c !=Null and Account_vod__c in :existMap.keySet()]

The extra check for Account_vod__c in :existMap.keySet() will stop you querying the records you are not interested in.

2: Change the for loop

Because you do your SOQL and store the results in a it means that ALL records will be on the heap. Try changing your for loop to the format shown below. This will avoid the heap issues are you are not storing all the results to a list:

for (Call2_vod__c call : [select ... from ... where ...]) {
    //
}

Doing number 2 will probably fix your issue but having the SOQL returning so many records is wrong and will cause problems as the number of Call2_vod__c records grow. For example: you will hit another limit if that query returns more than 10,000 records

added 20 characters in body
Source Link
BarCotter
  • 12.4k
  • 4
  • 38
  • 58

You are querying too many unneeded records and creating Attachments for them which is why you are hitting the heap limit. Try make the 2 changes listed below

1: Restrict your query

Changing the SOQL to have extra where conditions will mean you are querying less records which means less fields that are base64 encoded. The SOQL below is looking at the Account_vod__c fields which will mean you query less records.

[select Name,Id,Signature_vod__c,Signature_Date_vod__c,Account_vod__c 
    from  Call2_vod__c 
    where Signature_Date_vod__c !=Null and Account_vod__c in :existMap.keySet()]

2: Change the for loop

Because you do your SOQL and store the results in a it means that ALL records will be on the heap. Try changing your for loop to the format shown below. This will avoid the heap issues are you are not storing all the results to a list:

for (Call2_vod__c call : [select ... from ... where ...]) {
    //
}

Doing number 2 will probably fix your issue but having the SOQL returning so many records is wrong and will cause problems as the number of Call2_vod__c records grow. For example: you will hit another limit if that query returns more than 10,000 records

You are querying too many unneeded records and creating Attachments for them which is why you are hitting the heap limit. Try make the 2 changes listed below

1: Restrict your query

Changing the SOQL to have extra where conditions will mean you are querying less records which means less fields that are base64 encoded. The SOQL below is looking at the Account_vod__c fields which will mean you query less records.

[select Name,Id,Signature_vod__c,Signature_Date_vod__c,Account_vod__c from  Call2_vod__c where Signature_Date_vod__c !=Null and Account_vod__c in :existMap.keySet()]

2: Change the for loop

Because you do your SOQL and store the results in a it means that ALL records will be on the heap. Try changing your for loop to the format shown below. This will avoid the heap issues are you are not storing all the results to a list:

for (Call2_vod__c call : [select ... from ... where ...]) {
    //
}

You are querying too many unneeded records and creating Attachments for them which is why you are hitting the heap limit. Try make the 2 changes listed below

1: Restrict your query

Changing the SOQL to have extra where conditions will mean you are querying less records which means less fields that are base64 encoded. The SOQL below is looking at the Account_vod__c fields which will mean you query less records.

[select Name,Id,Signature_vod__c,Signature_Date_vod__c,Account_vod__c 
    from  Call2_vod__c 
    where Signature_Date_vod__c !=Null and Account_vod__c in :existMap.keySet()]

2: Change the for loop

Because you do your SOQL and store the results in a it means that ALL records will be on the heap. Try changing your for loop to the format shown below. This will avoid the heap issues are you are not storing all the results to a list:

for (Call2_vod__c call : [select ... from ... where ...]) {
    //
}

Doing number 2 will probably fix your issue but having the SOQL returning so many records is wrong and will cause problems as the number of Call2_vod__c records grow. For example: you will hit another limit if that query returns more than 10,000 records

Source Link
BarCotter
  • 12.4k
  • 4
  • 38
  • 58

You are querying too many unneeded records and creating Attachments for them which is why you are hitting the heap limit. Try make the 2 changes listed below

1: Restrict your query

Changing the SOQL to have extra where conditions will mean you are querying less records which means less fields that are base64 encoded. The SOQL below is looking at the Account_vod__c fields which will mean you query less records.

[select Name,Id,Signature_vod__c,Signature_Date_vod__c,Account_vod__c from  Call2_vod__c where Signature_Date_vod__c !=Null and Account_vod__c in :existMap.keySet()]

2: Change the for loop

Because you do your SOQL and store the results in a it means that ALL records will be on the heap. Try changing your for loop to the format shown below. This will avoid the heap issues are you are not storing all the results to a list:

for (Call2_vod__c call : [select ... from ... where ...]) {
    //
}