Re: Memory management limitations Win x Linux




=?ISO-8859-1?Q?Cl=E9ment_Doss?= <cdoss@xxxxxxxxxx> wrote:

Hi,

A friend of mine wrote a C++ program, and he has a problem.
This program depends on an algorithm he wrote that will allocate a lot of memory in
order to do some heavy calculations and produce some numbers.
He is using a linux and a native c++ compiler.

The fact is he need "a little more info" for his algorithm to be more effective, and
when he sets Ip=12000 and I=12000 (would be close to ideal), there's a bad_alloc
error. From what I can see, there's a 12000 * 12000 * 8 = 1.152.000.000 bytes and
12000 * 12000 * 8 * 3 = 3.456.000.000. What's 4.5Gb of ram of data for a 500 lines
C++ program? :-)

Is he taking the right approach if he needs such large arrays?


He asked me to convert the program to delphi and make some tests, but with the
figures above, I really couldn't give him any hope.

Simple. Compile the program with Free Pascal for x86_64. This
should make it work.

I downloaded turbo c++ explorer, and tried to compiled it. I ran the program but the
error is still there. With some nice hints by the way!! (Windows XP 2.5 Gb Ram)

As the memory grows, shouldn't some virtual memory kick in under windows? and under
linux?

No, you reach the limits of a 32-bit address space. A 64-bit
address space is required for such code to run. Virtual memory
only helps against lack of physical memory.

Anyway I wouldn't expect him to have such a problem (memory limitation) under linux.

You would, 32-bit Linux suffers from 32-bit limitations too.


I told him to change the "double" (64-bit) for "float" (32-bit) to see if that
affects the calculations. He is checking this write now. Ok this would cut in half
the memory consumption.

Is there any setting in the environment (or command line option, switch, flag) he can
make in order to compile and run such a memory consuming beast?

64-bit is the only solution. Well, or a better algorithm.

Daniël Mantione
.



Relevant Pages

  • [RFC][PATCH] A new memory algorithm for the embedded linux system
    ... the external fragmentation about linux memory management. ... it's not a best algorithm for the embedded linux system, ... Here I wrote a memory algorithm and I really hope it's a starting ... maintain a list in the zone, ...
    (Linux-Kernel)
  • Re: Turing Machines and Physical Computation
    ... rather than adumbrated in that 1936 Turing paper On Computable ... ... any actual computer has finite memory, ... computer will run out of memory for some huge calculation. ... It is generally assumed that an algorithm must satisfy the following ...
    (comp.theory)
  • Re: Turing Machines and Physical Computation
    ... rather than adumbrated in that 1936 Turing paper On Computable ... ... any actual computer has finite memory, ... computer will run out of memory for some huge calculation. ... It is generally assumed that an algorithm must satisfy the following ...
    (sci.math)
  • Solving the memory issue of lock-free algorithms
    ... I read a lot about lock-free algorithm and tried to find an "elegant" ... solution to the memory problem that the algorithms poses. ... LFStackNode *Next; ... xor eax, eax ...
    (comp.programming.threads)
  • Re: Version after Version
    ... MMX, by doing 50 times two additions at a time. ... Many compilers & memory managers have at least the option to align data on ... > - compression and decompression works at the Bit level ... > LZW is the until recently proprietory algorithm of Uinisys ...
    (alt.comp.lang.borland-delphi)