Re: NSData dataWithBytes:length:
Re: NSData dataWithBytes:length:
- Subject: Re: NSData dataWithBytes:length:
- From: Marcel Weiher <email@hidden>
- Date: Thu, 3 Jul 2003 20:57:06 +0200
On Thursday, July 3, 2003, at 08:03 Uhr, Brent Gulanowski wrote:
However, according to MallocDebug and top, memory used up by NSData
objects created using +dataWithBytes:length: seems never to be
released. I wrote a test program:
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
bytes = (char *)malloc(length);
This is the memory that doesn't get freed. You are allocating it with
malloc(), therefore you must free it with free().
data = [NSData dataWithBytes:bytes length:length];
The memory allocated by NSData gets released very nicely.
[pool release];
usleep( 10000 );
Marcel
--
Marcel Weiher Metaobject Software Technologies
email@hidden www.metaobject.com
Metaprogramming for the Graphic Arts. HOM, IDEAs, MetaAd etc.
1d480c25f397c4786386135f8e8938e4
_______________________________________________
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.