From 846212336aead0959d1e9b34d9b2f157f9e0ac94 Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Fri, 4 Apr 2014 16:53:58 -0400 Subject: [PATCH] Make use of a local pool to avoid over-memory usage --- ActiveSync/SOGoMailObject+ActiveSync.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ActiveSync/SOGoMailObject+ActiveSync.m b/ActiveSync/SOGoMailObject+ActiveSync.m index 05f448df3..eb4fcff3e 100644 --- a/ActiveSync/SOGoMailObject+ActiveSync.m +++ b/ActiveSync/SOGoMailObject+ActiveSync.m @@ -30,6 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "SOGoMailObject+ActiveSync.h" #import +#import #import #import #import @@ -479,7 +480,9 @@ struct GlobalObjectId { // - (NSString *) activeSyncRepresentationInContext: (WOContext *) _context { + NSAutoreleasePool *pool; NSData *d, *globalObjId; + NSArray *attachmentKeys; NSMutableString *s; id value; @@ -670,6 +673,10 @@ struct GlobalObjectId { // Body - namespace 17 preferredBodyType = [[context objectForKey: @"BodyPreferenceType"] intValue]; + // Make use of a local pool here as _preferredBodyDataUsingType:nativeType: will consume + // a significant amout of RAM and file descriptors + pool = [[NSAutoreleasePool alloc] init]; + nativeBodyType = 1; d = [self _preferredBodyDataUsingType: preferredBodyType nativeType: &nativeBodyType]; @@ -710,8 +717,10 @@ struct GlobalObjectId { [s appendString: @""]; } + DESTROY(pool); + // Attachments -namespace 16 - NSArray *attachmentKeys = [self fetchFileAttachmentKeys]; + attachmentKeys = [self fetchFileAttachmentKeys]; if ([attachmentKeys count]) { int i;