The E_OUTOFMEMORY error message is caused by the failure of the virtual
allocation to reserve a block of memory 64K times the size of a single row
in the rowset (ADO Recordset) that is being opened by the provider. The
address space reservation fails due to memory fragmentation in the
applications process address space, not due to an actual shortage of
memory.
NOTE: Memory managers normally include algorithms that address memory fragmentation. However, since Microsoft Data Access Components (MDAC) uses virtual memory directly (for performance gains) it bypasses the algorithms in the heap memory manager, thus allowing fragmentation to occur.
For example, for Internet Information Server applications this would be the
Internet Service Process (InetInfo.exe). Memory fragmentation occurs in the
Inetinfo.exe process address space when MDAC reserves and then releases
memory blocks on each page. If the row size is 200 bytes, then
MDAC will reserve a memory block 12.8 Meg in size. When combined with
smaller memory allocations that fill the large memory "holes" vacated by
the multiple-megabyte allocations. Further, smaller allocations on the same
page as the large allocation mean the page will not be released until all
allocations, large and small, have been released.
A diagram of how the memory fragmentation occurs follows:
- .........................................
- 7777777.................................. Large block reserved.
- 77777771................................. Small block allocated.
- .......1................................. Large block released.
- 1......1................................. Small block allocated.
- 1......17777777.......................... Large block reserved.
- 1......177777771......................... Small block allocated.
- 1......1.......1......................... Large block released.
- 1......1.......1......................... Small block allocated.
After numerous iterations of small and large allocations, the example
process address space becomes so fragmented that the large allocation no
longer fits in memory, resulting in the E_OUTOFMEMORY error.