Re: OLEDB, sql server, and memory leak

Tech-Archive recommends: Speed Up your PC by fixing your registry



If you are using SQL Server, then use SqlClient, not OleDb. It was
designed to work with SQL Server whereas OleDb is a more general
purpose API.

-mary

On Mon, 18 Jun 2007 10:47:18 -0700, pbx <pbeisel@xxxxxxxxx> wrote:


I am running a managed application (ASP.NET)... it is leaking
unmanaged memory.

Using the debug diagnostic tool 1.1, the dump analysis report shows
that:


msdatl3.dll (a known Windows memory manager) is responsible for 828.81
MBytes worth of outstanding allocations. These allocations
appear to have originated from the following module(s) and
function(s):

sqloledb!CDBConnection::GetColData+2c8


The code involved in this leak is performing a SELECT and then reads
the data. One db field of concern is typed nvarchar(MAX).

The code basically looks like this:

Dim x,y,x as String

Dim reader As OleDbDataReader

Dim sqlstr As String = "SELECT * FROM pages WHERE pID = some page id
Dim cmd As New OleDbCommand(sqlstr, db.getconnection())
reader = cmd.ExecuteReader

reader.Read()
If reader.HasRows() Then
x = reader("col1")
y = reader("col2")
z = reader("col3") ' where col3 is of type nvarchar(MAX)
End If

reader.Close()

The size of col3, nvarchar(MAX), varies between 2,000 and 80,000
bytes.


Question: what am I doing wrong? Am I failing to clean up in some
way (I thought all I had to do was close the reader). Is there a
different/better way to read the nvarchar(MAX) field?


thanks.
.



Relevant Pages

  • Re: Data access layer for SQL Server & MS Access
    ... To be honost I've never had any performance trouble using OleDb with ... SQL server - it all depends on what you're doing and how often. ... dim x as sqlDataReader, ... Could I not just avoid this and use OLEDB for both database types? ...
    (microsoft.public.dotnet.languages.vb)
  • Re: New to C# - DB question
    ... Close the reader before you close the connection. ... What you have done is used ADO.NET, but instead of SQL server ... you have used OleDb for Access ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: How to populate VBA Variables from ADODB.Connection Results?
    ... y As Integer 'Incremental counters to populate ... 'Find SQL Server data for the active user. ... "GetUserNameA" (ByVal lpBuffer As String, ... Dim UserName As String ...
    (microsoft.public.excel.programming)
  • Re: Programmatically changing a SQL view in a ADP
    ... Public Sub TestCreateView() ... Dim cn As ADODB.Connection ... Dim rst As ADODB.Recordset ... to alter the 'Select' statement of a SQL Server view from within a ADP ...
    (microsoft.public.access.modulesdaovba)
  • Passing values to an SQL Server backend database using a form
    ... I am trying to pass values from a form to an SQL Server 2000 DB using the ... OpenRecordSet method and then the .AddNew function. ... Dim recA As DAO.Recordset ... updated", vbInformation, "Information Conflict" ...
    (microsoft.public.access.modulesdaovba)