64 bit large mallocs

后端 未结 9 1908
情话喂你
情话喂你 2020-11-28 13:18

What are the reasons a malloc() would fail, especially in 64 bit?

My specific problem is trying to malloc a huge 10GB chunk of RAM on a 64 bit system. The machine ha

9条回答
  •  有刺的猬
    2020-11-28 14:23

    Just a guess here, but malloc allocates contiguous memory and you may not have a sufficiently large contiguous section on your heap. Here's a few things I would try;

    Where a 20GB malloc fails, do four 5GB mallocs succeed? If so, it is a contiguous space issue.

    Have you checked your compiler switches for anything that limits total heap size, or largest heap block size?

    Have you tried writing a program that declares a static variable of the required size? If this works you could implement your own heap with big mallocs in that space.

提交回复
热议问题