PRB: Jet Memory Usage Increases When You Insert New Records (313011)
The information in this article applies to:
- Microsoft OLE DB Provider for Jet 4.0
- Microsoft Data Access Components 2.1
- Microsoft Data Access Components 2.5
This article was previously published under Q313011 SYMPTOMS
When you use the OLE DB Provider for Jet to insert records into a Microsoft Access database file, if you use the AddNew and Update methods of the ActiveX Data Objects (ADO) Recordset object, the memory usage of Jet increases slowly but continuously. This memory is not released until you close the recordset.
CAUSE
The Jet provider maintains a "map" in memory of all new rows that you add to the rowset (or recordset). When the number of rows increases, the memory that is used for this map increases as well. This memory is not released until the recordset is closed.
RESOLUTIONWindows NT, Windows 2000, or Windows XP
On the Microsoft Windows NT, Windows 2000, or Windows XP platform, the Jet provider allocates this memory from the 2 gigabytes of addressable virtual memory; therefore, Microsoft does not anticipate that the provider's memory usage will become problematic for customers. Our tests suggest that you must call AddNew more than 11 million times to exhaust even half (1 gigabyte) of the addressable virtual memory. Furthermore, you must call AddNew more than 11 million times without ever restarting the application or closing the recordset or its connection to use this amount of virtual memory. If an application must support this volume of inserts without interruption, Microsoft strongly recommends that you use the more robust Microsoft SQL Server database platform instead of the Jet desktop database engine.
You can also use the following workarounds to control or to minimize the memory usage of the Jet provider:
- Use the MaxBufferSize registry setting with the value 512.
For additional information, click the article number below
to view the article in the Microsoft Knowledge Base:
248014 PRB: Jet OLE DB Provider Consuming Too Much Memory
When Microsoft tested this workaround on Windows XP Professional Edition, the virtual memory for 100,000 inserts is reduced from approximately 18 megabytes to approximately 15 megabytes. - Use SQL INSERT statements with the Execute method of the ADO Connection or Command object. This approach avoids the memory usage issue entirely and is more efficient for ADO. However, when you concatenate SQL INSERT strings in Microsoft Visual Basic, you may reduce the performance gain.
- Close the ADO recordset periodically, and reopen it immediately if necessary. This releases the memory that the Jet Provider previously held for its "map" of newly inserted rows.
Windows 98 or Windows Me
This can become a significant problem on systems that are running Windows 98 or Windows Millennium Edition (Me) because the memory for the map is reallocated every 64 records. Windows 98 and Windows Me handle memory management at the application level very differently than Windows NT, Windows 2000, or Windows XP. When the map is reallocated, memory becomes fragmented. No workaround exists for this type of memory fragmentation on Windows 98 or Windows Me because this is a limitation of the operating system.
STATUSThis behavior is by design.
Modification Type: | Major | Last Reviewed: | 11/17/2003 |
---|
Keywords: | kbDatabase kbJET kbprb KB313011 |
---|
|