From dec4f24aa44abccd9c311e9cbb440f32198ef3e2 Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 30 Sep 2021 09:13:28 -0400 Subject: [PATCH] fix(addressbook): use pool to lower memory usage --- SoObjects/Contacts/SOGoContactSourceFolder.m | 12 +++++++++++- SoObjects/SOGo/SQLSource.m | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/SoObjects/Contacts/SOGoContactSourceFolder.m b/SoObjects/Contacts/SOGoContactSourceFolder.m index 41fa9a3d05..62cb4a1239 100644 --- a/SoObjects/Contacts/SOGoContactSourceFolder.m +++ b/SoObjects/Contacts/SOGoContactSourceFolder.m @@ -18,6 +18,7 @@ * Boston, MA 02111-1307, USA. */ +#import #import #import @@ -650,6 +651,7 @@ - (void) _appendComponentProperties: (NSArray *) properties matchingURLs: (id ) refs toResponse: (WOResponse *) response { + NSAutoreleasePool *pool; NSObject *element; NSString *url, *baseURL, *cname, *domain; NSString **propertiesArray; @@ -668,9 +670,10 @@ - (void) _appendComponentProperties: (NSArray *) properties propertiesCount = [properties count]; max = [refs length]; - buffer = [NSMutableString stringWithCapacity: max*512]; + buffer = [[NSMutableString alloc] initWithCapacity: max*512]; domain = [[context activeUser] domain]; connection = [source connection]; + pool = [[NSAutoreleasePool alloc] init]; for (count = 0; count < max; count++) { element = [refs objectAtIndex: count]; @@ -688,8 +691,15 @@ - (void) _appendComponentProperties: (NSArray *) properties else [self appendMissingObjectRef: url toBuffer: buffer]; + if (count % 10 == 0) + { + RELEASE(pool); + pool = [[NSAutoreleasePool alloc] init]; + } } + RELEASE(pool); [response appendContentString: buffer]; + RELEASE(buffer); // NSLog (@"/adding properties with url"); NSZoneFree (NULL, propertiesArray); diff --git a/SoObjects/SOGo/SQLSource.m b/SoObjects/SOGo/SQLSource.m index 6ffd63b93e..8465752d0b 100644 --- a/SoObjects/SOGo/SQLSource.m +++ b/SoObjects/SOGo/SQLSource.m @@ -1,6 +1,6 @@ /* SQLSource.h - this file is part of SOGo * - * Copyright (C) 2009-2020 Inverse inc. + * Copyright (C) 2009-2021 Inverse inc. * * This file is part of SOGo. *