Can you allocate a very large single chunk of memory ( > 4GB ) in c or c++?

后端 未结 10 814
面向向阳花
面向向阳花 2020-12-02 10:46

With very large amounts of ram these days I was wondering, it is possible to allocate a single chunk of memory that is larger than 4GB? Or would I need to allocate a bunch o

10条回答
  •  星月不相逢
    2020-12-02 11:05

    If size_t is greater than 32 bits on your system, you've cleared the first hurdle. But the C and C++ standards aren't responsible for determining whether any particular call to new or malloc succeeds (except malloc with a 0 size). That depends entirely on the OS and the current state of the heap.

提交回复
热议问题