Article ID: 834279 - Last Review: March 28, 2008 - Revision: 5.5 Methods to dispose of SQL Server CE, SQL Server 2005 Compact Edition, or SQL Server 2005 Mobile Edition managed objects from memorySUMMARYThis article discusses the different ways to dispose of the
managed objects in Microsoft SQL Server 2000 Windows CE Edition, in Microsoft SQL Server 2005 Compact Edition, or in SQL Server 2005 Mobile Edition that are used in applications that you create by using Microsoft Visual Studio .NET that use the Microsoft .NET Compact Framework. MORE INFORMATIONThe .NET Compact Framework Data Provider for SQL Server CE, SQL Server 2005 Compact Edition, or SQL Server 2005 Mobile Edition
supports a collection of classes, including the SqlCeCommand class, the SqlCeConnection class,
and the SqlCeDataReader class. You can use the objects that are the instances of these
classes to gain access to a SQL Server CE, SQL Server 2005 Compact Edition, or SQL Server 2005 Mobile Edition database from devices that are running Microsoft Windows CE in
a managed environment. However, you must release the memory that is allocated
to the objects if the objects are no longer required. You can use the following methods to release the memory that is allocated to the objects of the classes. Note Microsoft recommends that you use the Close() method or the Dispose() method and the following coding style to release the memory for the objects of the .NET classes that contain native references.
REFERENCESFor more information about the IDisposable interface, visit the
following Microsoft Web site: http://msdn2.microsoft.com/en-us/library/system.idisposable(vs.71).aspx
(http://msdn2.microsoft.com/en-us/library/system.idisposable(vs.71).aspx)
For more information about
the GC.Collect() method, visit the following Microsoft Web site:http://msdn2.microsoft.com/en-us/library/aa903907(VS.71).aspx
(http://msdn2.microsoft.com/en-us/library/aa903907(VS.71).aspx)
For more information about
the SqlCeConnection.Close method, visit the following Microsoft Web
site:http://msdn2.microsoft.com/en-us/library/system.data.sqlserverce.sqlceconnection.close(vs.71).aspx
(http://msdn2.microsoft.com/en-us/library/system.data.sqlserverce.sqlceconnection.close(vs.71).aspx)
For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
824462
(http://support.microsoft.com/kb/824462/
)
SqlCeCommand objects are not automatically disposed if you use a SqlCeDataAdapter object
326164
(http://support.microsoft.com/kb/326164/
)
Dumpmem utility for viewing virtual address space on Pocket PC 2002
827837
(http://support.microsoft.com/kb/827837/
)
FIX: SQL Server CE connection causes an out-of-memory condition when you create many SqlCeDataReader objects
APPLIES TO
| Article Translations
|
Back to the top
