where static objects live in memory.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • puzzlecracker

    #1

    where static objects live in memory.

    Dynamically allocated objects reside on a heap, local objects on a
    stack. What about static objects?

    Thanks

  • Gianni Mariani

    #2
    Re: where static objects live in memory.

    puzzlecracker wrote:
    Dynamically allocated objects reside on a heap, local objects on a
    stack. What about static objects?
    Same place as globals. Referred to sometimes as "global" memory, or
    "global and static" memory.

    Comment

    • MAx

      #3
      Re: where static objects live in memory.

      On Sep 14, 7:13 am, Gianni Mariani <gi3nos...@mari ani.wswrote:
      puzzlecracker wrote:
      Dynamically allocated objects reside on a heap, local objects on a
      stack. What about static objects?
      >
      Same place as globals. Referred to sometimes as "global" memory, or
      "global and static" memory.
      Globas and Statics reside in the Datasegment of the address space.


      Thanks
      MAx

      Comment

      • =?ISO-8859-1?Q?Erik_Wikstr=F6m?=

        #4
        Re: where static objects live in memory.

        On 2007-09-14 13:42, MAx wrote:
        On Sep 14, 7:13 am, Gianni Mariani <gi3nos...@mari ani.wswrote:
        >puzzlecracke r wrote:
        Dynamically allocated objects reside on a heap, local objects on a
        stack. What about static objects?
        >>
        >Same place as globals. Referred to sometimes as "global" memory, or
        >"global and static" memory.
        >
        Globas and Statics reside in the Datasegment of the address space.
        The BSS segment to be more accurate (Data segment can be confused with
        the data region which contains the code and constants and is usually
        read only).

        However C++ does not specify these things, it does not even require that
        variables with automatic storage are stored on a stack, the closest it
        comes to discussing a stack is the concept of stack unwinding when
        exceptions are thrown.

        --
        Erik Wikström

        Comment

        • James Kanze

          #5
          Re: where static objects live in memory.

          On Sep 14, 2:55 pm, Erik Wikström <Erik-wikst...@telia. comwrote:
          On 2007-09-14 13:42, MAx wrote:
          On Sep 14, 7:13 am, Gianni Mariani <gi3nos...@mari ani.wswrote:
          puzzlecracker wrote:
          Dynamically allocated objects reside on a heap, local objects on a
          stack. What about static objects?
          Same place as globals. Referred to sometimes as "global" memory, or
          "global and static" memory.
          Globas and Statics reside in the Datasegment of the address space.
          The BSS segment to be more accurate (Data segment can be confused with
          the data region which contains the code and constants and is usually
          read only).
          It depends very much on the implementation. The name BSS
          segment is a Unix'ism, I think: the original Unix on PDP-11 had
          three "segments": data, bss and stack. (From what I have heard,
          the name bss came from the name of the segment register in the
          MMU of the PDP-11.) Basically, the data segment had a fixed
          size, the bss segment could grow up, and the stack segment could
          grow down. The data segment held the program itself, and all
          initialized data; bss was for uninitialized data and dynamically
          allocated memory. Very, very quickly, a fourth, write protected
          segment, called text, was added for the code (but not for
          initialized data, which could be changed during run-time---there
          was no const back then).
          However C++ does not specify these things, it does not even require that
          variables with automatic storage are stored on a stack, the closest it
          comes to discussing a stack is the concept of stack unwinding when
          exceptions are thrown.
          And in fact, I once used a C compiler where the "stack" was
          allocated dynamically on the heap: function calls and returns
          were a bit expensive (the equivalent of a malloc/free), but
          memory use was a lot more flexible. (Not that it mattered. The
          machine on which it ran was a mainframe, which was normally
          outfitted with over 16 MB, compared to the 64-256 KB which was
          current on most machines at the time.)

          --
          James Kanze (GABI Software) email:james.kan ze@gmail.com
          Conseils en informatique orientée objet/
          Beratung in objektorientier ter Datenverarbeitu ng
          9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

          Comment

          • Jerry Coffin

            #6
            Re: where static objects live in memory.

            In article <1189844224.111 230.303950@g4g2 000hsf.googlegr oups.com>,
            james.kanze@gma il.com says...

            [ ... ]
            It depends very much on the implementation. The name BSS
            segment is a Unix'ism, I think: the original Unix on PDP-11 had
            three "segments": data, bss and stack. (From what I have heard,
            the name bss came from the name of the segment register in the
            MMU of the PDP-11.)
            The name predates Unix by a fair amount. AFAIK, it originated on IBM
            mainframes.

            [ ... ]
            However C++ does not specify these things, it does not even require that
            variables with automatic storage are stored on a stack, the closest it
            comes to discussing a stack is the concept of stack unwinding when
            exceptions are thrown.
            >
            And in fact, I once used a C compiler where the "stack" was
            allocated dynamically on the heap: function calls and returns
            were a bit expensive (the equivalent of a malloc/free), but
            memory use was a lot more flexible. (Not that it mattered. The
            machine on which it ran was a mainframe, which was normally
            outfitted with over 16 MB, compared to the 64-256 KB which was
            current on most machines at the time.)
            Sounds some of those same IBM mainframes.

            --
            Later,
            Jerry.

            The universe is a figment of its own imagination.

            Comment

            • James Kanze

              #7
              Re: where static objects live in memory.

              On Sep 15, 8:20 pm, Jerry Coffin <jcof...@taeus. comwrote:
              In article <1189844224.111 230.303...@g4g2 000hsf.googlegr oups.com>,
              james.ka...@gma il.com says...
              [ ... ]
              It depends very much on the implementation. The name BSS
              segment is a Unix'ism, I think: the original Unix on PDP-11 had
              three "segments": data, bss and stack. (From what I have heard,
              the name bss came from the name of the segment register in the
              MMU of the PDP-11.)
              The name predates Unix by a fair amount. AFAIK, it originated on IBM
              mainframes.
              Interesting. As I said, I remember hearing it. I don't
              remember where, or from whom, so I have no idea as to the
              reliability of my source. (But it wasn't anything official.)
              [ ... ]
              However C++ does not specify these things, it does not
              even require that variables with automatic storage are
              stored on a stack, the closest it comes to discussing a
              stack is the concept of stack unwinding when exceptions
              are thrown.
              And in fact, I once used a C compiler where the "stack" was
              allocated dynamically on the heap: function calls and returns
              were a bit expensive (the equivalent of a malloc/free), but
              memory use was a lot more flexible. (Not that it mattered. The
              machine on which it ran was a mainframe, which was normally
              outfitted with over 16 MB, compared to the 64-256 KB which was
              current on most machines at the time.)
              Sounds some of those same IBM mainframes.
              Siemens mainframes. The instruction set of which was more or
              less IBM mainframe compatible, at least in user mode.

              --
              James Kanze (GABI Software) email:james.kan ze@gmail.com
              Conseils en informatique orientée objet/
              Beratung in objektorientier ter Datenverarbeitu ng
              9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

              Comment

              • Pete Becker

                #8
                Re: where static objects live in memory.

                On 2007-09-15 16:29:14 -0400, James Kanze <james.kanze@gm ail.comsaid:
                On Sep 15, 8:20 pm, Jerry Coffin <jcof...@taeus. comwrote:
                >In article <1189844224.111 230.303...@g4g2 000hsf.googlegr oups.com>,
                >james.ka...@gm ail.com says...
                >
                >[ ... ]
                >
                >>It depends very much on the implementation. The name BSS
                >>segment is a Unix'ism, I think: the original Unix on PDP-11 had
                >>three "segments": data, bss and stack. (From what I have heard,
                >>the name bss came from the name of the segment register in the
                >>MMU of the PDP-11.)
                >
                >The name predates Unix by a fair amount. AFAIK, it originated on IBM
                >mainframes.
                >
                Interesting. As I said, I remember hearing it. I don't
                remember where, or from whom, so I have no idea as to the
                reliability of my source. (But it wasn't anything official.)
                >
                For what it's worth, my understanding (from the late 60s) is that BSS
                is an acronym, standing for Block Starting Symbol, that is, a block of
                memory associated with a symbolic name that refers to the first
                location in the block. There's also BES, for Block Ending Symbol, where
                the symbolic name refers to the end of the block (I don't remember
                whether it's the last location in the block or the first one after the
                block).

                --
                Pete
                Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
                Standard C++ Library Extensions: a Tutorial and Reference
                (www.petebecker.com/tr1book)

                Comment

                Working...