• 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: NSData being retained?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSData being retained?


  • Subject: Re: NSData being retained?
  • From: Jim Ways <email@hidden>
  • Date: Thu, 22 Jul 2004 11:50:00 -0700 (PDT)

Here is a breakdown of what i am doing

NSAutoreleasePool *mainPool = [[NSAutoreleasePool
alloc] init];

while(looping)
{
NSAutoreleasePool *localPool = [[NSAutoreleasePool
alloc] init];

NSString *urlString = a_string_i_got_from_somewhere
NSURL* aUrl = [NSURL URLWithString:urlString];
NSData *data = [aUrl resourceDataUsingCache:NO];
[aUrl release]; //with or without this line i get it

[localPool release];
}

[mainPool release];

--- Shawn Erickson <email@hidden> wrote:
>
> On Jul 22, 2004, at 11:13 AM, Jim Ways wrote:
>
> > NSURL* aUrl = [NSURL URLWithString:urlString];
> > NSData *data = [aUrl resourceDataUsingCache:NO];
> > [aUrl release];
>
> In the above data is returned to you autoreleased
> (since the
> resourceDataUsingCache method allocated the object).
>
> > This allocates memory but never releases it, if i
> > [data release]; i get a bus error.
>
> The bus error implies that data is getting released
> to many times at
> some point and likely your explicit release is one
> to many.
>
> > If i set data to
> > nil i still get an increase in memory each loop.
>
> What type of loop? The NSApp event loop or your own
> looping of some
> type?
>
> > The
> > contents of data dont seem to increase with each
> cycle
> > but i cant track down where the memory is comming
> > from.
>
> It sounds like you are looping getting autoreleased
> objects allocated
> but not taking steps to allocate/release a local
> auto release pool to
> keep the object build up to a reasonable level while
> you loop.
>
> Review the following...
>
>
<http://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/
>
> Concepts/AutoreleasePools.html>
>
> -Shawn
>
>




__________________________________
Do you Yahoo!?
Vote for the stars of Yahoo!'s next ad campaign!
http://advision.webevents.yahoo.com/yahoo/votelifeengine/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: NSData being retained?
      • From: James DiPalma <email@hidden>
    • Re: NSData being retained?
      • From: Nick Zitzmann <email@hidden>
References: 
 >Re: NSData being retained? (From: Shawn Erickson <email@hidden>)

  • Prev by Date: keyedobjects.nib
  • Next by Date: Re: Redirecting screencapture output
  • Previous by thread: Re: keyedobjects.nib
  • Next by thread: Re: NSData being retained?
  • Index(es):
    • Date
    • Thread