Skip to content

Commit

Permalink
fix(addressbook): use pool to lower memory usage
Browse files Browse the repository at this point in the history
  • Loading branch information
cgx committed Sep 30, 2021
1 parent 4884cb3 commit dec4f24
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion SoObjects/Contacts/SOGoContactSourceFolder.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* Boston, MA 02111-1307, USA.
*/

#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSValue.h>

#import <NGObjWeb/NSException+HTTP.h>
Expand Down Expand Up @@ -650,6 +651,7 @@ - (void) _appendComponentProperties: (NSArray *) properties
matchingURLs: (id <DOMNodeList>) refs
toResponse: (WOResponse *) response
{
NSAutoreleasePool *pool;
NSObject <DOMElement> *element;
NSString *url, *baseURL, *cname, *domain;
NSString **propertiesArray;
Expand All @@ -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];
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion SoObjects/SOGo/SQLSource.m
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down

0 comments on commit dec4f24

Please sign in to comment.