How much memory should you be able to allocate?

前端 未结 8 1013
失恋的感觉
失恋的感觉 2020-12-31 17:36

Background: I am writing a C++ program working with large amounts of geodata, and wish to load large chunks to process at a single go. I am constrained to working with an a

相关标签:
8条回答
  • 2020-12-31 18:36

    With nBandBytes at 466,560,000, you are trying to allocate 1.4 GB. A 32-bit app typically only has access to 2 GB of memory (more if you boot with /3GB and the executable is marked as large address space aware). You may be hard pressed to find that many blocks of contiguous address space for your large chunks of memory.

    If you want to allocate gigabytes of memory on a 64-bit OS, use a 64-bit process.

    0 讨论(0)
  • 2020-12-31 18:37

    Even if you allocate in smaller chunks, you couldn't get the memory you need, especially if the surrounding program has unpredictable memory behavior, or if you need to run on different operating systems. In my experience, the heap space on a 32-bit process caps at around 1.2GB.

    At this amount of memory, I would recommend manually writing to disk. Wrap your arrays in a class that manages the memory and writes to temporary files when necessary. Hopefully the characteristics of your program are such that you could effectively cache parts of that data without hitting the disk too much.

    0 讨论(0)
提交回复
热议问题