From 1585c3daab05dc4607086913e5a948c4eef727c7 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 6 Feb 2009 20:12:42 +0000 Subject: [PATCH] Monotone-Parent: aa77eb2904bbe4270428126e707735db8d28bea4 Monotone-Revision: 2da3fdffb894897d29ea164dddd960be3c7f92bf Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2009-02-06T20:12:42 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 6 ++++++ Main/SOGo.m | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/ChangeLog b/ChangeLog index aa15b09bc..1252aa993 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2009-02-06 Wolfgang Sourdeau + * Main/SOGo.m ([SOGo +initialize]): added handling of the + "SOGoDebugLeaks" configuration variable. + ([SOGo -dispatchRequest:_request]): log the classes of instances + that were leaked between the handling of the request, if + SOGoDebugLeaks is set. + * SoObjects/SOGo/SOGoGCSFolder.m ([SOGoGCSFolder -aclsForUser:uidforObjectAtPath:objectPathArray]): cache an empty array if not acl have been returned for the specified user. diff --git a/Main/SOGo.m b/Main/SOGo.m index 06e5c0942..11a4bad6b 100644 --- a/Main/SOGo.m +++ b/Main/SOGo.m @@ -19,6 +19,7 @@ 02111-1307, USA. */ +#import #import #import #import @@ -64,6 +65,7 @@ static unsigned int vMemSizeLimit = 0; static BOOL doCrashOnSessionCreate = NO; static BOOL hasCheckedTables = NO; static BOOL debugRequests = NO; +static BOOL debugLeaks = NO; #ifdef GNUSTEP_BASE_LIBRARY static BOOL debugObjectAllocation = NO; @@ -91,6 +93,7 @@ static BOOL debugObjectAllocation = NO; } #endif debugRequests = [ud boolForKey: @"SOGoDebugRequests"]; + debugLeaks = [ud boolForKey: @"SOGoDebugLeaks"]; /* vMem size check - default is 200MB */ tmp = [ud objectForKey: @"SxVMemLimit"]; @@ -394,6 +397,7 @@ static BOOL debugObjectAllocation = NO; static NSArray *runLoopModes = nil; WOResponse *resp; NSDate *startDate, *endDate; + NSAutoreleasePool *pool; if (debugRequests) { @@ -403,6 +407,13 @@ static BOOL debugObjectAllocation = NO; } cache = [SOGoCache sharedCache]; + if (debugLeaks) + { + GSDebugAllocationActive (YES); + GSDebugAllocationList (NO); + pool = [NSAutoreleasePool new]; + } + resp = [super dispatchRequest: _request]; [SOGoCache killCache]; @@ -413,6 +424,15 @@ static BOOL debugObjectAllocation = NO; [endDate timeIntervalSinceDate: startDate]]; } + if (debugLeaks) + { + [resp retain]; + [pool release]; + [resp autorelease]; + NSLog (@"allocated classes:\n%s", GSDebugAllocationList (YES)); + GSDebugAllocationActive (NO); + } + if (![self isTerminating]) { if (!runLoopModes)