• 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: Memory Allocation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory Allocation


  • Subject: Re: Memory Allocation
  • From: "Alexandre Badez" <email@hidden>
  • Date: Wed, 16 Jul 2008 21:35:22 +0200

On Wed, Jul 16, 2008 at 20:38, Kyle Sluder
<email@hidden> wrote:
> On Wed, Jul 16, 2008 at 2:02 PM, Alexandre Badez
> <email@hidden> wrote:
>> -(id)init
>> {
>>    if (![super init])
>>        return nil;
>
> You must always assign self to the result of [super init].  If anyone
> (*cough* Wil Shipley *cough*) tells you otherwise, they may
> inadvertently set you up for some seriously subtle errors.
>
> So the code would be:
>
> - (id)init
> {
>  if(self = [super init])  // single = is intentional
>    NSLog(@"-[%@ init]", [self className]);
>
>  return self;
> }

Thanks for this tips !


> Anyway, your problem is here:
>
>>    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
>
> Why are you doing this?  AppKit creates an autorelease pool for you.

Well actually, I did not put this autorelease pool in my first
attempt. But when I've that the prog was growing in ObjectAlloc, I
though that I should create a pool to drain autorelease NSString
returned by stringWithFormat:.
The fact is that even with this pool, the memory is still growing...

Any idea about that ? Is it my fault ?

--
Alex
_______________________________________________

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

References: 
 >Memory Allocation (From: "Alexandre Badez" <email@hidden>)
 >Re: Memory Allocation (From: "Kyle Sluder" <email@hidden>)

  • Prev by Date: Re: Mystery Thread - how to debug
  • Next by Date: Re: Relaunch Finder (without AppleScript)
  • Previous by thread: Re: Memory Allocation
  • Next by thread: Re: Memory Allocation
  • Index(es):
    • Date
    • Thread