Out of memory error

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

    #1

    Out of memory error

    Hi all !

    I have a problem. I need to use two huge variables (square matrices), 500
    MBytes each. My memory is 3GB RAM and 3GB swap. 300M of them occupied by
    system.

    Memory for the first one allocates well, without problems. But when program
    tries to allocate memory for second matrix, "Out of memory" error occurs.
    But there is a great amount of free memory !!!

    Can you tell me, what is the reason and how I can fix it. Is there any
    VisualC 7.0 tuning, connected with memory allocation ? It's acceptably to
    storage variables in the swap. Is there any compiler directive, which
    specify, that variable can be moved into the swap ?

    I didn't find answers in the MSDN disk documentation. May be, someone know
    the title of the Articles, connected with these questions.

    Thank you, and sorry for my English :-)
  • Bo Persson

    #2
    Re: Out of memory error


    "Anatoly" <Anatoly@discus sions.microsoft .com> skrev i meddelandet
    news:FF30B85E-19E4-4BA3-ACE1-D939F86E84E4@mi crosoft.com...[color=blue]
    > Hi all !
    >
    > I have a problem. I need to use two huge variables (square
    > matrices), 500
    > MBytes each. My memory is 3GB RAM and 3GB swap. 300M of them
    > occupied by
    > system.
    >
    > Memory for the first one allocates well, without problems. But when
    > program
    > tries to allocate memory for second matrix, "Out of memory" error
    > occurs.
    > But there is a great amount of free memory !!!
    >
    > Can you tell me, what is the reason and how I can fix it. Is there
    > any
    > VisualC 7.0 tuning, connected with memory allocation ? It's
    > acceptably to
    > storage variables in the swap. Is there any compiler directive,
    > which
    > specify, that variable can be moved into the swap ?
    >
    > I didn't find answers in the MSDN disk documentation. May be,
    > someone know
    > the title of the Articles, connected with these questions.
    >
    > Thank you, and sorry for my English :-)[/color]

    It's not a matter of how much memory space you have, but how
    fragmented it is. Usually, the user address space is 2 GB (with the
    other 2GBG reserved to the system). This doesn't mean that you can
    allocate one 2 GB element, but that the sum of all your allocated
    memory can approach 2 GB.

    After you have allocated the first 500 MB element, there may very well
    be enough space available to allocate 5 * 100 MB, but perhaps not a
    single 500 MB element. When entering a parking lot, there might easily
    be places for 5 cars, but perhaps not one single space for 5 cars.

    Do you really (really!) need to have the elements allocated in such
    big pieces, or can you possibly split them up in several smaller
    parts?



    Bo Persson


    Comment

    • Anatoly

      #3
      Re: Out of memory error

      "Bo Persson" wrote:
      [color=blue]
      > It's not a matter of how much memory space you have, but how
      > fragmented it is. Usually, the user address space is 2 GB (with the
      > other 2GBG reserved to the system). This doesn't mean that you can
      > allocate one 2 GB element, but that the sum of all your allocated
      > memory can approach 2 GB.
      >
      > After you have allocated the first 500 MB element, there may very well
      > be enough space available to allocate 5 * 100 MB, but perhaps not a
      > single 500 MB element. When entering a parking lot, there might easily
      > be places for 5 cars, but perhaps not one single space for 5 cars.
      > Bo Persson[/color]

      Thank you.
      The problem in the time - in future the program will be optimized and
      matrices will be much smaller, but now we need to solve some tasks quickly.

      Do you know, how can I order the compiler to allocate memory as compactly,
      as possible, witout "holes" ?

      Comment

      • Bob Milton

        #4
        Re: Out of memory error

        Anatoly,
        You're best bet is to have your program allocate the two 500MB arrays on
        the heap when it first starts. There is less likely to be any memory
        fragmentation when you first start. You will, of course, have to pass
        pointers to this allocated memory to the routines that need them, but that
        is a small price to pay.
        Bob Milton

        "Anatoly" <Anatoly@discus sions.microsoft .com> wrote in message
        news:281A6046-8750-439C-948C-670CFFF59734@mi crosoft.com...[color=blue]
        > "Bo Persson" wrote:
        >[color=green]
        >> It's not a matter of how much memory space you have, but how
        >> fragmented it is. Usually, the user address space is 2 GB (with the
        >> other 2GBG reserved to the system). This doesn't mean that you can
        >> allocate one 2 GB element, but that the sum of all your allocated
        >> memory can approach 2 GB.
        >>
        >> After you have allocated the first 500 MB element, there may very well
        >> be enough space available to allocate 5 * 100 MB, but perhaps not a
        >> single 500 MB element. When entering a parking lot, there might easily
        >> be places for 5 cars, but perhaps not one single space for 5 cars.
        >> Bo Persson[/color]
        >
        > Thank you.
        > The problem in the time - in future the program will be optimized and
        > matrices will be much smaller, but now we need to solve some tasks
        > quickly.
        >
        > Do you know, how can I order the compiler to allocate memory as compactly,
        > as possible, witout "holes" ?[/color]


        Comment

        • Pavel A.

          #5
          Re: Out of memory error

          Hi,

          Assuming that you really need a random access array so big, try to
          get a Windows Server system that supports 3 GB for user mode (/3GB boot
          switch)
          or a system that supports PAE.
          In the latter case you'll need to use special AWE API to allocate the memory
          and manage the mapping window (it is not a true random access)

          --PA

          "Anatoly" wrote:[color=blue]
          > "Bo Persson" wrote:
          >[color=green]
          > > It's not a matter of how much memory space you have, but how
          > > fragmented it is. Usually, the user address space is 2 GB (with the
          > > other 2GBG reserved to the system). This doesn't mean that you can
          > > allocate one 2 GB element, but that the sum of all your allocated
          > > memory can approach 2 GB.
          > >
          > > After you have allocated the first 500 MB element, there may very well
          > > be enough space available to allocate 5 * 100 MB, but perhaps not a
          > > single 500 MB element. When entering a parking lot, there might easily
          > > be places for 5 cars, but perhaps not one single space for 5 cars.
          > > Bo Persson[/color]
          >
          > Thank you.
          > The problem in the time - in future the program will be optimized and
          > matrices will be much smaller, but now we need to solve some tasks quickly.
          >
          > Do you know, how can I order the compiler to allocate memory as compactly,
          > as possible, witout "holes" ?[/color]

          Comment

          Working...