Skip navigation.
 
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection
FROM : Chris Suter
DATE : Tue Feb 19 23:42:03 2008

On 20/02/2008, at 8:12 AM, Quincey Morris wrote:

>  which means there are 3 possible avenues for dealing with this case 
> of optimization fragility, not just the 2 you mentioned:
>
> 1. Enhance GC (code generation and runtime) to work with interior 
> pointers.


I'm not convinced this would work. See earlier e-mail.

> 2. Be careful not to let the non-interior pointer variable's 
> lifetime expire before you're done with the interior pointer.


This is little better than using malloc and free.

> and
>
> 3. Enhance Objective-C -- to warn about or disallow certain patterns 
> of interior pointer usage, say, or to generate code that preserves 
> the base pointer reference when pointer arithmetic is used.


This won't work for libraries that you have no control over. For 
example, you might pass -[NSString UTF8String] to other library 
routines that aren't Objective C and have no knowledge of garbage 
collection (which is a fairly common usage pattern).

The only solution that I can see is viable is the one I proposed—use 
autoreleased memory for these kinds of temporary objects.

- Chris

Related mailsAuthorDate
mlAccessing buffers in NSData/NSMutableData under garbage collection Rick Hoge Feb 18, 23:21
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Adam P Jenkins Feb 19, 06:00
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection mmalc crawford Feb 19, 06:07
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Adam P Jenkins Feb 19, 06:19
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Adam P Jenkins Feb 19, 06:23
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Chris Suter Feb 19, 07:24
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Alastair Houghton Feb 19, 12:48
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Adam P Jenkins Feb 19, 15:26
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Alastair Houghton Feb 19, 15:46
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Quincey Morris Feb 19, 19:36
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Chris Suter Feb 19, 19:38
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Michael Ash Feb 19, 20:03
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Alastair Houghton Feb 19, 20:28
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Quincey Morris Feb 19, 22:12
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Chris Suter Feb 19, 23:42
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Quincey Morris Feb 20, 00:35
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Michael Ash Feb 20, 00:44
mlRe: Accessing buffers in NSData/NSMutableData under garbage collection Chris Suter Feb 20, 00:59