• 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: SMySQL releasing the Results or Am I misunderstanding Autorelease?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SMySQL releasing the Results or Am I misunderstanding Autorelease?


  • Subject: Re: SMySQL releasing the Results or Am I misunderstanding Autorelease?
  • From: Uli Kusterer <email@hidden>
  • Date: Sat, 26 Nov 2005 15:01:51 +0100

Am 26.11.2005 um 11:58 schrieb Ole Voß:
1) I could release the Result (which is already 'autorelease') after I'm done with it - but waaaay ahead of the end of the event- cycle.
Q) Am I allowed to release Objects which are marked 'autorelease' when I'm certain that they are no longer required?

No, don't do that. The release would happen twice (once your "release" and then again in the "autorelease"), and it would crash on the second call because you'd be sending a message to an object that's already been released.


2) I could put the whole query in a seperate thread.
Q) But I believe this would not really change anything since each thread has its own autorelease-pool?!

You really want to read up on the NSAutoreleasePool class. Basically you can create your own autorelease pool objects that will catch all autorelease calls until you dispose of them again. So, if you're doing a loop:


for( int x = 0; x < 999999; x++ )
{
	NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

	// Do work with lots of autoreleases here

[pool release]; // Release the pool here, and all objects autoreleased while it existed.
}


(That's essentially what NSApplication/NSRunLoop do during the event loop) Usually, you wouldn't release the pool during each iteration, but rather only every N iterations or so.

Cheers,
-- M. Uli Kusterer
http://www.zathras.de


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >SMySQL releasing the Results or Am I misunderstanding Autorelease? (From: Ole Voß <email@hidden>)

  • Prev by Date: Re: how to know the home directory and its name?
  • Next by Date: Re: registerPrioritySleepWakeInterest problems with shutdown event
  • Previous by thread: SMySQL releasing the Results or Am I misunderstanding Autorelease?
  • Next by thread: how to know the home directory and its name?
  • Index(es):
    • Date
    • Thread