Allocate Static Memory?

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

    Allocate Static Memory?

    I want to know how much static memory is limited before execution
    program starts. I would write a large array. The large array has 65,536
    elements. The data size is double word. The static memory would allocate
    256K. The 256K is a fixed memory size. After the compiler has completed
    compiling header and source code, the execution program might fail to run or
    crash. The operating system might do not display error message saying,
    "Insufficie nt memory."
    The dynamic memory may be the option. The malloc() function can test to
    determine if allocated memory is available at run-time. Then, use I/O like
    fopen() and fclose() functions to read data from the hard drive and store it
    into RAM. The error message can display at run-time if malloc() tests to
    tell insufficient memory.
    Please give me your advice. How much static memory can be limited
    before execution program starts?

    --

    Yours Truly,
    Bryan Parkoff


  • Dann Corbit

    #2
    Re: Allocate Static Memory?

    "Bryan Parkoff" <nospam@nospam. comwrote in message
    news:481fc7cd$0 $7692$4c368faf@ roadrunner.com. ..
    I want to know how much static memory is limited before execution
    program starts. I would write a large array. The large array has 65,536
    elements. The data size is double word. The static memory would allocate
    256K. The 256K is a fixed memory size. After the compiler has completed
    compiling header and source code, the execution program might fail to run
    or crash. The operating system might do not display error message saying,
    "Insufficie nt memory."
    The dynamic memory may be the option. The malloc() function can test
    to determine if allocated memory is available at run-time. Then, use I/O
    like fopen() and fclose() functions to read data from the hard drive and
    store it into RAM. The error message can display at run-time if malloc()
    tests to tell insufficient memory.
    Please give me your advice. How much static memory can be limited
    before execution program starts?
    There is no simple answer to your question. It will depend on your
    hardware, on your operating system, on your compiler, on what other programs
    are in memory at the time, on how much virtual memory you have, and
    (possibly) on your user limit and a number of other factors.

    The malloc() function is also dependent upon all of the above things.
    Automatic memory is even more limited.

    The best way to find out if you can get a block of memory of a certain size
    is to attempt to allocate it. If the allocation fails, then you can't get
    it.


    ** Posted from http://www.teranews.com **

    Comment

    • Robert Gamble

      #3
      Re: Allocate Static Memory?

      On May 5, 10:50 pm, "Bryan Parkoff" <nos...@nospam. comwrote:
      I want to know how much static memory is limited before execution
      program starts. I would write a large array. The large array has 65,536
      elements. The data size is double word. The static memory would allocate
      256K. The 256K is a fixed memory size. After the compiler has completed
      compiling header and source code, the execution program might fail to run or
      crash. The operating system might do not display error message saying,
      "Insufficie nt memory."
      The dynamic memory may be the option. The malloc() function can test to
      determine if allocated memory is available at run-time. Then, use I/O like
      fopen() and fclose() functions to read data from the hard drive and store it
      into RAM. The error message can display at run-time if malloc() tests to
      tell insufficient memory.
      Please give me your advice. How much static memory can be limited
      before execution program starts?
      The only thing the Standard says is in this regard is that a hosted
      environment must allow an object of at least 65,535 bytes to be
      created (32,767 bytes for C89). This doesn't mean that multiple
      objects of this size can be created or that multiple objects totaling
      this limit must be allowed and it isn't specified whether the limit be
      achievable via static or dynamic allocation. For more details you
      will need to consult the documentation for your implementation.

      --
      Robert Gamble

      Comment

      • Peter Nilsson

        #4
        Re: Allocate Static Memory?

        Robert Gamble wrote:
        ...
        The ... Standard says ... that a hosted
        environment must allow an object of at least 65,535 bytes
        to be created (32,767 bytes for C89).
        Strictly speaking, it only says that an implementation must
        accept one program with a number of features. There is
        nothing to say that a different program allocating the same
        memory will succeed. [Not that it's an easy thing to define.]

        All you can say is that it's not portable to allocate an object
        larger than the minimum size.

        --
        Peter

        Comment

        • Nick Keighley

          #5
          Re: Allocate Static Memory?

          On 6 May, 03:50, "Bryan Parkoff" <nos...@nospam. comwrote:
              I want to know how much static memory is limited before execution
          program starts.
          this is platform (OS + hardware) specific.
          > I would write a large array.  The large array has 65,536
          elements.  The data size is double word.  The static memory would
          allocate 256K.  
          this isn't an enormous amount on a modern system.


          The 256K is a fixed memory size.  After the compiler has completed
          compiling header and source code, the execution program might fail to run or
          crash.  
          what do mean "might"? Does it crash? always? sometimes?
          The operating system might do not display error message saying,
          "Insufficie nt memory."
          "might"? I think you might be using non-standard english.

          Look, 256k is a *tiny* amount of memory (unless you are
          programming a toaster). Are you certain its a memory problem?
          Try reucing the static memory to a much smaller amount.
          Does it still crash? It may not be a memory problem.

          Is your code small enough to post here?

          <snip>


          --
          Nick Keighley

          Comment

          • Charlton Wilbur

            #6
            Re: Allocate Static Memory?

            >>>>"BP" == Bryan Parkoff <nospam@nospam. comwrites:

            BP I want to know how much static memory is limited before
            BPexecution program starts.

            This is system-specific. It definitely varies based on hardware and
            operating system, and may also vary by compiler even when the hardware
            and operating system are the same.

            BPThe dynamic memory may be the option. The malloc() function
            BPcan test to determine if allocated memory is available at
            BPrun-time. Then, use I/O like fopen() and fclose() functions
            BPto read data from the hard drive and store it into RAM. The
            BPerror message can display at run-time if malloc() tests to
            BPtell insufficient memory. Please give me your advice.

            In theory, sure. In practice, not so much. Some environments may
            restrict the amount of memory you have available (such as per-process
            limits in BSD); others may tell you there is memory available when
            there is not (such as overcommitting in Linux).

            My advice is to figure out what problem you are *really* trying to
            solve and to solve that problem instead.

            Charlton


            --
            Charlton Wilbur
            cwilbur@chromat ico.net

            Comment

            • Chris Thomasson

              #7
              Re: Allocate Static Memory?

              "Bryan Parkoff" <nospam@nospam. comwrote in message
              news:481fc7cd$0 $7692$4c368faf@ roadrunner.com. ..
              I want to know how much static memory is limited before execution
              program starts. I would write a large array. The large array has 65,536
              elements. The data size is double word. The static memory would allocate
              256K. The 256K is a fixed memory size. After the compiler has completed
              compiling header and source code, the execution program might fail to run
              or crash. The operating system might do not display error message saying,
              "Insufficie nt memory."
              The dynamic memory may be the option. The malloc() function can test
              to determine if allocated memory is available at run-time. Then, use I/O
              like fopen() and fclose() functions to read data from the hard drive and
              store it into RAM. The error message can display at run-time if malloc()
              tests to tell insufficient memory.
              Please give me your advice. How much static memory can be limited
              before execution program starts?
              This is off-topic wrt your question, but you can build an allocator on a
              plurality of threads stack spaces... I did a memory allocation scheme in an
              environment that did not have a heap. IIRC, the OS was an older version of
              Quadros on ARM9. No, heap, but each Quadros Task had stack space. So, I
              built the heap on a per-thread/task allocation algorithm. Something like:



              But it used bin-sema for locks instead of atomic operations. The only atomic
              operation available on the ARM9 is a SWP instruction. I also used some stack
              space for a globally shared heap. The entire allocation system was based on
              task stacks.

              Comment

              • Noob

                #8
                Re: Allocate Static Memory?

                Nick Keighley wrote:
                [256 KiB] isn't an enormous amount on a modern system.
                Indeed!

                How to use a terabyte of RAM
                We have not yet reached a point where systems - even high-end boxes - come with a terabyte of i [...]

                Comment

                • Ian Collins

                  #9
                  Re: Allocate Static Memory?

                  Noob wrote:
                  Nick Keighley wrote:
                  >
                  >[256 KiB] isn't an enormous amount on a modern system.
                  >
                  Indeed!
                  >
                  How to use a terabyte of RAM
                  http://lwn.net/Articles/273030/
                  Systems with >1TB of RAM have been around for a while, no real challenge
                  for Oracle to fill it....

                  --
                  Ian Collins.

                  Comment

                  • Noob

                    #10
                    Re: Allocate Static Memory?

                    Ian Collins wrote:
                    Systems with >1TB of RAM have been around for a while
                    I had *affordable* systems in mind :-)

                    (Going on a tangent.)



                    "It supports up to 512 sockets under one instance of Linux and as
                    much as 128TB of globally shared memory."

                    I'm confused. Assuming 8-GiB DIMMs, how does one fit 16384 DIMMs
                    in a single system? How does one fit 512 CPUs in a single system?

                    Is the system as big as a large fridge with a huge backplane, and
                    tens of daughter boards which accept DIMMs and CPUs?

                    What I had in mind was a system with a single ATX motherboard.
                    I think 16 DIMM slots is the maximum, or I am mistaken?
                    e.g. http://www.tyan.com/product_board_detail.aspx?pid=560

                    16x8 = 128 GiB which still is a nice number.

                    Comment

                    • Ian Collins

                      #11
                      [OT] Re: Allocate Static Memory?

                      Noob wrote:
                      Ian Collins wrote:
                      >
                      >Systems with >1TB of RAM have been around for a while
                      >
                      I had *affordable* systems in mind :-)
                      >
                      (Going on a tangent.)
                      >

                      >
                      "It supports up to 512 sockets under one instance of Linux and as
                      much as 128TB of globally shared memory."
                      >
                      I'm confused. Assuming 8-GiB DIMMs, how does one fit 16384 DIMMs
                      in a single system? How does one fit 512 CPUs in a single system?
                      >
                      It's a blade system with fancy interconnects.

                      If you want to see a (big!) single box system, try
                      Lower TCO with powerful, on-premise Oracle hardware solutions that include unique Oracle Database optimizations and Oracle Cloud integrations.


                      --
                      Ian Collins.

                      Comment

                      • CBFalconer

                        #12
                        Re: Allocate Static Memory?

                        Noob wrote:
                        Nick Keighley wrote:
                        >
                        >[256 KiB] isn't an enormous amount on a modern system.
                        >
                        Indeed!
                        I can remember being very grateful when I got a second 4k bytes of
                        memory. 1968 or so. It cost about $1500. Shortly afterward a
                        CP/M machine with 62k of main memory was a very powerful beastie.
                        About 2000 I was working with a PIC chip, which had a staggering
                        256 bytes of main memory available. No expansion, although we
                        could build an i/o system to address a full 64k externally. Just
                        fill the address register (2 bytes), then either read or write a
                        whole byte. This ate up at least 3 of the basic 256 memory.

                        --
                        [mail]: Chuck F (cbfalconer at maineline dot net)
                        [page]: <http://cbfalconer.home .att.net>
                        Try the download section.


                        ** Posted from http://www.teranews.com **

                        Comment

                        Working...