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

后端 未结 10 795
面向向阳花
面向向阳花 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条回答
  •  Happy的楠姐
    2020-12-02 11:21

    This shouldn't be a problem with a 64-bit OS (and a machine that has that much memory).

    If malloc can't cope then the OS will certainly provide APIs that allow you to allocate memory directly. Under Windows you can use the VirtualAlloc API.

提交回复
热议问题