Is there a constraint to the size of arrays for the NEW operator?

Joseph Klasen 146 Reputation points

Assuming a workstation with 128 GB of ram, what is the maximum array size that Windows will accept in say:

BYTE* ByteArray;

ByteArray = new BYTE[XXXXX};

Assuming say 100GB is available on the heap, is there a constraint to the value of XXXXX in this example?

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,186 questions
{count} votes

Accepted answer
  1. WayneAKing 4,356 Reputation points

    Memory limitations for processes are based on virtual memory,
    not physical memory (RAM).

    The max memory available for a given process depends on whether
    it is x86 or x64, which version of WIndows the process is running
    under, whether or not the program was built with


    set or cleared, etc.


    Memory Limits for Windows and Windows Server Releases

    Within these constraints, the max size that a dynamic allocated array
    can have depends on how much of the process's memory space is available considering all other demands on that space. Code, other dynamic allocations, etc. all deplete the available heap.

    Note that allocating all of the available heap via new[], malloc,
    etc. can result in other parts of the program failing later when
    an attempt is made to acquire space from the heap. This may occur
    within library code such as expanding class objects such as
    vectors, lists, maps, strings, etc.

    • Wayne

0 additional answers

Sort by: Most helpful