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

后端 未结 10 825
面向向阳花
面向向阳花 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:06

    it depends on which C compiler you're using, and on what platform (of course) but there's no fundamental reason why you cannot allocate the largest chunk of contiguously available memory - which may be less than you need. And of course you may have to be using a 64-bit system to address than much RAM...

    see Malloc for history and details

    call HeapMax in alloc.h to get the largest available block size

提交回复
热议问题