fix(addressbook): use pool to lower memory usage

This commit is contained in:
Francis Lachapelle
2021-09-30 09:13:28 -04:00
parent 4884cb3978
commit dec4f24aa4
2 changed files with 12 additions and 2 deletions

View File

@@ -18,6 +18,7 @@
* Boston, MA 02111-1307, USA.
*/
#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSValue.h>
#import <NGObjWeb/NSException+HTTP.h>
@@ -650,6 +651,7 @@
matchingURLs: (id <DOMNodeList>) refs
toResponse: (WOResponse *) response
{
NSAutoreleasePool *pool;
NSObject <DOMElement> *element;
NSString *url, *baseURL, *cname, *domain;
NSString **propertiesArray;
@@ -668,9 +670,10 @@
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 @@
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);

View File

@@ -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.
*