0

在XLW library的帮助下,我正在使用 C++ 为 Microsoft Excel 编写一个 .XLL 插件。我的操作系统是windows 7 64位版本,32 GB RAM;但我的 Excel 是 Excel 2010,32 位版本。

检查GlobalMemoryStatusEx,它显示 XLL 中的代码只能看到大约 1200 MB 的可用虚拟内存(来自ullAvailVirtualstruct _MEMORYSTATUSEX),尽管可用的物理内存(ullAvailPhys)大约是 23 GB。

由于我的代码需要相当多的内存(每个计算线程大约 100MB),在发出 12 个线程后它会遇到错误的分配错误。

有没有办法增加可用内存?

  1. 这是 ExcelXLL插件的限制吗?在控制台应用程序中,GlobalMemoryStatusEx报告大约 2034 MB 可用虚拟内存。
  2. 这是一个限制XLW library吗?
  3. 这是一个限制32-bit Excel吗?
4

1 回答 1

1

An XLL is actually just a renamed DLL. If you have a 32-bit Excel, then the whole Excel process has a 32-bit virtual address space to live in (and Windows reserves half of that for the OS). So your process (both XLL and Excel itself), is limited to a total of 2G.

Your choices are:

  1. Switch to a 64-bit Excel (which implies that your XLL will need to be 64-bit)
  2. Let the XLL remain 32-bit, and make it launch a separate (possibly 64-bit) process, and do the processing in that.

The latter option is obviously much more complicated, and copying data between processes will not be that snappy - but it is an option.

于 2016-12-08T11:41:47.213 回答