• 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: How turn-off C-run time library memory diagnostics?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: How turn-off C-run time library memory diagnostics?


  • Subject: RE: How turn-off C-run time library memory diagnostics?
  • From: Erik Buck <email@hidden>
  • Date: Fri, 5 Aug 2005 11:33:58 -0400

malloc() and free() do not have particularly "fast" performance on any non-real-time Unix variant. If you think malloc() and free() are hard to use in high performance code, try automatic garbage collection sometime :(


The solution that real-time software developers have used for the last 25 years at least is to not dynamically allocate memory. Standard alternatives include a one time large malloc() or vmalloc() or mmap() in the beginning and using/reusing that buffer over and over. Free or munmap() the buffer outside "fast" code or just before application exit or never.


I assume you are using Cocoa. There is an example in "Cocoa Programming" that reuses the same memory buffer for multiple instances of NSString. You don't even have to buy the book (although an inexpensive digital version is available). You can just download the examples from www.cocoaprogramming.net. If you have the book, see Section "Avoiding Dynamic Memory Allocation" in Appendix B "Optimizing and Finding Memory Leaks."



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: How turn-off C-run time library memory diagnostics?
      • From: Gen Kiyooka <email@hidden>
  • Prev by Date: Re: Cocoa-dev Digest, Vol 2, Issue 1205Re: ComboBox Questions
  • Next by Date: Re: NSNumberFormatter localize bug in IB?
  • Previous by thread: How turn-off C-run time library memory diagnostics?
  • Next by thread: Re: How turn-off C-run time library memory diagnostics?
  • Index(es):
    • Date
    • Thread