• 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: C types and memory management
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C types and memory management


  • Subject: Re: C types and memory management
  • From: Ondra Cada <email@hidden>
  • Date: Mon, 24 Jun 2002 22:53:16 +0200

On Monday, June 24, 2002, at 09:56 , James Winetke wrote:

My reading suggests, but does not say clearly, that plain C types like
these are allocated in a range of memory called the stack, and are
automatically deallocated when their scope ends.

Right. Applies for all local variables, actually -- for object pointers (which is what id or NSString* are) the pointer -- a four-byte word -- is allocated on the stack as well.

Is this accurate? If so, is it a complete description of what's going on?

Yup. Any local variable is allocated on the stack. Beside them, it contains also backtrack of calls (the standard frame including the return address), and, rarely enough, chunks allocated explicitly at stack (by calling a function I can't just remember, sorry -- never needed it myself.
Kinda recall it might be something in line "aalloc", "aut_alloc", or remotely alike).

How can I find out how much space is free in the stack?

Unless you use *big* local C-arrays or *very very heavy* recursion, there'
s enough space. Frankly, I don't know whether there is a function to get the theoretical stack size at all; it would be difficult to compute anyway,
for -- so far as I know -- the heap and stack grow one against the other,
with a problem occurring only if they meet. With any at least marginally normal code, they won't (the space would be -- just guessing here! -- about a gig or so).
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
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: C types and memory management
      • From: Jim Correia <email@hidden>
References: 
 >C types and memory management (From: "James Winetke" <email@hidden>)

  • Prev by Date: C types and memory management
  • Next by Date: Re: Mixing Carbon events & Cocoa
  • Previous by thread: C types and memory management
  • Next by thread: Re: C types and memory management
  • Index(es):
    • Date
    • Thread