title: Getting heap size error while serializing collection of records in apex
body: <p>I am suffering with Salesforce apex LimitException issue. I am fetching thousands of records from few objects and putting it into the collection like Map. Now I have a requirement to generate JSON for same records which will be used for mobile devices to download data from Salesforce.
  When I tried to serialize those records by using System.JSON.Serialize() method; it is generating a huge JSON string and I am getting System.LimitException error because there will be more memory required than available space.
  I tried to catch that issue using try/catch block but here is a reference available which says that System.LimitException can’t be caught by Catch block.
  Referral URL: </p>
  
  <p><a href="http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_exception_methods.htm" rel="nofollow">http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_exception_methods.htm</a></p>
  
  <p>I know that we can check heap size limit through Limits.getHeapSize() method. But is there any work around so that I can handle this issue from apex side.
  A code sample or some reference in this regard would be highly appreciated.
  Thanks in advanced.</p>