• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Solving memory leaks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Solving memory leaks


  • Subject: Solving memory leaks
  • From: Michael Davey <email@hidden>
  • Date: Sun, 28 Mar 2010 18:37:57 +0100

> -(NSDictionary *)fetch {
> 	NSMutableDictionary *output = nil;
> 	if (db != nil && sth != nil) {
> 		int c = sqlite3_column_count(sth);
> 		if (fields == nil) {
> 			fields = [[NSMutableArray alloc] init];
> 			for (int i = 0; i < c; ++i) {
> 				const char *name = sqlite3_column_name(sth, i);
> 				[fields addObject:[NSString stringWithUTF8String:name]];
> 			}
> 		}
> 		if (sqlite3_step(sth) == SQLITE_ROW) {
> 			output = [[[NSMutableDictionary alloc] init] autorelease];
> 			for (int i = 0; i < c; ++i) {
> 				const unsigned char *val = sqlite3_column_text(sth, i);
> 				NSString *value;
> 				if (val == nil) {
> 					value = @"{NULL}";
> 				}
> 				else {
> 					value = [NSString stringWithUTF8String:(char *)val];
> 				}
> 				[output setObject:value forKey:[fields objectAtIndex:i]];
> 			}
> 		}
> 	}
> 	return output;
> }

However, can anyone answer how I best go about either of the tasks that I have outlined as red, as they are leaking a lot of memory in comparison?_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Solving memory leaks
      • From: mmalc Crawford <email@hidden>
References: 
 >Solving memory leaks (From: Michael Davey <email@hidden>)

  • Prev by Date: Re: Solving memory leaks
  • Next by Date: Re: Solving memory leaks
  • Previous by thread: Re: Solving memory leaks
  • Next by thread: Re: Solving memory leaks
  • Index(es):
    • Date
    • Thread