I have been investigating a potential heap size problem in our production code, and I wanted to recreate some simple elements through the developer console.
To cause a heap size exception, I would select every standard field from account for 50,000 accounts into a list.
System.debug('Heap size before query = ' + Limits.getHeapSize() + ', out of maximum ' + Limits.getLimitHeapSize()); List<Account> accs = [select AccountNumber, AccountSource, AnnualRevenue, BillingCity, BillingCountry, BillingPostalCode, BillingState, BillingStreet, CreatedById, CreatedDate, CurrencyIsoCode, Description, Fax, FirstName, Id, Industry, IsCustomerPortal, IsDeleted, IsPersonAccount, Jigsaw, JigsawCompanyId, LastActivityDate, LastModifiedById, LastModifiedDate, LastName, MasterRecordId, Name, NumberOfEmployees, OwnerId, Ownership, ParentId, PersonBirthdate, PersonContactId, PersonEmail, PersonEmailBouncedDate, PersonEmailBouncedReason, PersonHomePhone, PersonLastCURequestDate, PersonLastCUUpdateDate, PersonLeadSource, PersonMailingCity, PersonMailingCountry, PersonMailingPostalCode, PersonMailingState, PersonMailingStreet, PersonMobilePhone, PersonOtherCity, PersonOtherCountry, PersonOtherPostalCode, PersonOtherState, PersonOtherStreet, PersonTitle, Phone, Rating, RecordTypeId, Salutation, ShippingCity, ShippingCountry, ShippingPostalCode, ShippingState, ShippingStreet, Sic, SicDesc, Site, SystemModstamp, TickerSymbol, Type, Website from account limit 50000]; System.debug('Heap size after query = ' + Limits.getHeapSize() + ', out of maximum ' + Limits.getLimitHeapSize());
This is a full copy sandbox and there are over 50,000 accounts. My expectation was that this would fail with a heap size limit exception.
Instead I get the output:
USER_DEBUG |DEBUG|Heap size before query = 1069, out of maximum 6000000 USER_DEBUG |DEBUG|Heap size after query = 33931975, out of maximum 6000000
Notice the heap size used is 34MB and the limit 6MB but no exception occurs. I have done some more experiments and I can iterate over the list and carry on executing code with the heap size above this level.
Here are the limit usage stats which seem to show 0 heap usage.
I can't find anywhere that this is expected behaviour for the developer console. My understanding was that the limits apply in all contexts.
Can anyone shed any light on this?