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

Simple memory problem


  • Subject: Simple memory problem
  • From: harry greenmonster <email@hidden>
  • Date: Thu, 5 Feb 2009 23:39:14 +0000

while([inputString isMatchedByRegex:regexString]){

	range = [inputString rangeOfRegex:regexString];

inputString = [inputString stringByReplacingCharactersInRange:range withString:@""];

	}



'inputString' is a 5mb text file, Activity Monitor shows that memory increases by about 9mb per iteration. Which quickly becomes a serious problem.

I'm a little confused as to why I have a problem. My understanding is that 'inputString' (on the third line) is replaced by the modified version of itself. I was expecting the memory footprint for the app to reduce in size (if anything). Obviously I have the concept fundamentally wrong in my head.

a pointer address when replaced by another address free's up the old memory location it once pointed to, no?

By the way I'm using RegexKit. And I'm a little rusty as have not programed the mac for some considerable time.
_______________________________________________


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: Shawn Erickson <email@hidden>
    • Re: Simple memory problem
      • From: Ken Thomases <email@hidden>
    • Re: Simple memory problem
      • From: Nick Zitzmann <email@hidden>
    • Re: Simple memory problem
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: underlining
  • Next by Date: Re: Needed : set class for Cocoa
  • Previous by thread: Re: Needed : set class for Cocoa
  • Next by thread: Re: Simple memory problem
  • Index(es):
    • Date
    • Thread