4

I'm fairly sure that Remoting is Asynchronous. The docs state that the Apex heap size limit is 6Mb for a Synchronous op, and 12Mb for an Asynchronous op. However, from my RemoteAction (@Readonly) call I'm getting errors like

Apex heap size too large: 6041150

which I assume refers to bytes. Am I misunderstanding here? The only reason I need heap size at all is to get around the limit of 2000 for OFFSET statements.

  • you could also consider having the controller do a REST GET on the same org passing as the query parm the SOQL. If too many results would come back, SFDC does an implicit query more pattern that lets you decide when to fetch the next chunk. – cropredy Oct 28 '14 at 4:53
5

Yes, it's bytes, and yes, synchronous calls are limited to 6MB.

To reduce total heap usage, use a query-more loop:

Integer skipRows = 10000;
Account[] results = new Account[0];
for(Account record:[SELECT Id, Name FROM Account LIMIT 12000]) {
    if(skipRows-- < 0) {
        results.add(record);
    }
}

This "query-more" loop uses only as much heap as necessary for 200 results plus the size of the result list.

3

My understanding is that RemoteActions are not considered 'async' because they are executed immediately. That is, future methods and batch jobs get queued and executed whenever Salesforce has free cycles and so are considered 'async', whereas RemoteActions get executed immediately regardless of server load so are still treated as synchronous.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.