• 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: heap memory among shared libraries
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: heap memory among shared libraries


  • Subject: Re: heap memory among shared libraries
  • From: Greg Titus <email@hidden>
  • Date: Tue, 25 Sep 2001 14:51:33 -0700

On Tuesday, September 25, 2001, at 02:32 PM, Jeff Howe wrote:

I am not sure if this is the proper group in which to ask
this question, but I'll try it here:

If I have two shared libraries, say, two frameworks used in
the same application, is it safe to malloc (or new) an object
in one framework, and free (or delete) it in the other one?

Yep, absolutely. (Assuming, of course, that the first framework isn't _also_ going to try to free/delete the object later on. If so, you get into the whole retain counting thing that Cocoa does.)

Each application has a single heap for dynamically allocated memory. It doesn't matter where allocations and deallocations occur as far as various libraries / frameworks / app code is concerned.

Also different from Classic MacOS, this heap is visible only to that single application (that whole protected memory thing...) and is automatically destroyed when the application exits, reclaiming all memory. (It has been interesting seeing some of the questions on this list - presumably from former classic programmers - trying to manually clean things up before the application exits. I am _so_ happy not to have had to deal with things like that.)

Hope this helps,
--Greg


  • Follow-Ups:
    • Re: heap memory among shared libraries
      • From: Chris Kane <email@hidden>
  • Prev by Date: heap memory among shared libraries
  • Next by Date: RE: heap memory among shared libraries
  • Previous by thread: Re: heap memory among shared libraries
  • Next by thread: Re: heap memory among shared libraries
  • Index(es):
    • Date
    • Thread