Re: Accessing buffers in NSData/NSMutableData under garbage collection
Re: Accessing buffers in NSData/NSMutableData under garbage collection
- Subject: Re: Accessing buffers in NSData/NSMutableData under garbage collection
- From: Chris Suter <email@hidden>
- Date: Wed, 20 Feb 2008 10:59:53 +1100
On 20/02/2008, at 10:35 AM, Quincey Morris wrote:
On Feb 19, 2008, at 14:42, Chris Suter wrote:
The only solution that I can see is viable is the one I proposed—
use autoreleased memory for these kinds of temporary objects.
OK, I'll fess up and admit I don't know what this means. At what
point does the lifetime of such an object end?
It's exactly the same as how it used to work in the non GC world. In
the old world -[NSString UTF8String] would have created an auto-
released object (that you don't get to access) and when it gets
released (i.e. when the associated auto-release pool gets released)
the memory pointed to by --[NSString UTF8String] gets released. The
problem with it is that it relies on you releasing an auto-release
pool periodically (or equivalent) which is fine for the main thread
but it's a pain to ask the user to do that for secondary threads—so
maybe it's not the best solution after all. :-)
Thinking about it now, maybe a better way is if you can flag return
values to the compiler so that the compiler ensures that the return
value is left on the stack or in a register for the lifetime of the
callers stack frame. But then that has its own issues—you can't
reclaim the memory until the function returns.
Hmm, it's a tricky one to solve. Thankfully I don't have to solve it
and I'm not using GC.
- Chris
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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