Re: NSData dataWithBytes:length:
Re: NSData dataWithBytes:length:
- Subject: Re: NSData dataWithBytes:length:
- From: Thomas Finley <email@hidden>
- Date: Thu, 3 Jul 2003 15:15:51 -0400
On Thursday, July 3, 2003, at 02:03 PM, Brent Gulanowski wrote:
bytes = (char *)malloc(length);
One obvious memory leak is this. +dataWithBytes:length: creates data
that is a _copy_ of the specified memory block. It does not merely
reference the memory block. I repeated your experiment while freeing
"bytes" after creating the data item, and I did not observe anything
out of line while viewing with "top". I also repeated your experiment
with +dataWithBytesNoCopy:length: (and not freeing "bytes" this time),
which seems closer to what your intentions and expectations are, and
also observed no memory leak. This can easily explain your problems.
_______________________________________________
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.