How many memory an Excel XLL plugin can have?

187 views Asked by At

I'm using C++ to write a .XLL plugin for Microsoft Excel, with the help of XLW library. My operating system is windows 7 64-bit version, with 32 GB RAM; but my Excel is Excel 2010, 32-bits version.

Checking with GlobalMemoryStatusEx, it shows that the code in XLL can only see about 1200 MB virtual memory available (from ullAvailVirtual in struct _MEMORYSTATUSEX), though the physical memory available (ullAvailPhys) is around 23 GB.

As my code requires quite a lot memory (about 100MB per computation thread), after issuing 12 threads it hits the bad allocation error.

Is there a way to increase the memory available?

  1. Is this a limitation of Excel XLL plugin? In a Console Application, GlobalMemoryStatusEx reports around 2034 MB Virtual Memory available.
  2. Is this a limitation of XLW library?
  3. Is this a limitation of 32-bit Excel?
1

There are 1 answers

4
Martin Bonner supports Monica On BEST ANSWER

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.