Re: where does function reside in memory in C++

From: Sean (anonymous_at_discussions.microsoft.com)
Date: 08/18/04


Date: Tue, 17 Aug 2004 17:24:18 -0700

Hi Will,

Thanks for your reply.
I'm just curious since we ocassionally have function
pointers and I was wondering where
the pointers point to? :)

regards,
Sean

>-----Original Message-----
>"Sean" <anonymous@discussions.microsoft.com> wrote in
message
>news:7e9901c4849e$174fa010$a401280a@phx.gbl...
>> I know that some variables are stored on heaps and some
on
>> stack in C++. How about functions? where does function
>> reside on memory? Is it stack or heap?
>
>Neither. When you run an application, Windows' loader
inspects the image
>file, pre-allocates memory and copies the binary
executable (functions and
>all) into the memory. This memory is not considered to be
stack or heap. Why
>do you want to know?
>
>> And are both function (not class member) and method
>> (function in a class) stored in the same location
(either
>> stack or heap)?
>
>As above.
>
>I sense a bit of confusion, here. :-)
>
>Stack and heap are used for dynamic allocations though
most stack
>allocations have much shorter lifetimes, functions tend
to "live" for the
>life of an application.
>
>Regards,
>Will
>
>
>.
>



Relevant Pages

  • Re: Help wanted - problems with heap
    ... Memory pressure, because of limited heap size. ... identified that by failures to allocate memory. ... Any pointers as to work out what is happening would be welcome. ...
    (rec.games.roguelike.development)
  • Re: Help wanted - problems with heap
    ... Memory pressure, because of limited heap size. ... Any pointers as to work out what is happening would be welcome. ... interface expects to own that object from then on and delete it at its ...
    (rec.games.roguelike.development)
  • Re: run-time vs compile-time
    ... > offset related to some location (like stack base) somewhere. ... > offset from heap to pi. ... When you allocate an int on the heap, it is allocated at address 1. ... application has a given amount of memory it can use as it wishes. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: run-time vs compile-time
    ... > offset related to some location (like stack base) somewhere. ... > offset from heap to pi. ... When you allocate an int on the heap, it is allocated at address 1. ... application has a given amount of memory it can use as it wishes. ...
    (comp.lang.cpp)
  • Re: Error Raising and Memory in VB (general question)
    ... > object is terminated go out of scope, and the memory is also released. ... But why are you saying it uses stack? ... I think we are dealing with heap memory here. ... "COM's IMalloc allocator: ...
    (microsoft.public.vb.general.discussion)