• 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: NSData dataWithBytes:length:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.
  • Follow-Ups:
    • Re: NSData dataWithBytes:length:
      • From: Brent Gulanowski <email@hidden>
References: 
 >NSData dataWithBytes:length: (From: Brent Gulanowski <email@hidden>)

  • Prev by Date: Re: NSData dataWithBytes:length:
  • Next by Date: Re: NSData dataWithBytes:length:
  • Previous by thread: Re: NSData dataWithBytes:length:
  • Next by thread: Re: NSData dataWithBytes:length:
  • Index(es):
    • Date
    • Thread