• 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
Re: Simple memory problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple memory problem


  • Subject: Re: Simple memory problem
  • From: Steve Sisak <email@hidden>
  • Date: Thu, 5 Feb 2009 19:42:27 -0500

At 12:17 AM +0000 2/6/09, harry greenmonster wrote:
So, how do I keep a copy hanging around AND kill the mysterious new copy then (which shares the same name as the old one presumably)?

Retain the copy you want to keep around manually:


while([inputString isMatchedByRegex:regexString]) { NSAutoreleasePool* pool = [NSAutoreleasePool new];

	range = [inputString rangeOfRegex:regexString];

NSString * newString = [inputString stringByReplacingCharactersInRange:range withString:@""];

	[inputString release]; // release old inputString

	inputString = [newString retain]; // retain new inputString

	[pool drain];
}

WARING: this code not tested for correctness but should give you the idea

The autorelease pool may or may not be necessary here, but given the size of the input may be good defensive coding.

-Steve
_______________________________________________

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: Simple memory problem
      • From: Martin Wierschin <email@hidden>
  • Prev by Date: Re: IKImageView selection issue
  • Next by Date: NSTask + incomplete stdout at end of process
  • Previous by thread: Re: Simple memory problem
  • Next by thread: Re: Simple memory problem
  • Index(es):
    • Date
    • Thread