Possible Memory Leak When Using ADO/DAO with VB6 
Author Message
 Possible Memory Leak When Using ADO/DAO with VB6

I would be very greateful  if anyone can help with the following:
When using DAO and ADO with VB it appears that VB does not always
release the
memory it uses for the recordset objects even after I have closed the
recordset and or set it to nothing, I wrote a little test program that
opened an ADO connection to
an SQL server 7 database and opened and closed 3 recordset objects. It
appears to
deallocate some of the memory after closing the recordsets but does not
deallocate
around 4K. so if I repeatedly open and close the recordsets the memory
allocation after it stabilises, is 4K greater, I am using NT Task
Manager to monitor the mem allocation,
I am using NT 4.0 Enterprise Edition SP6, and VB 6 (no service pack)

The main problem is I have wrote some software which converts text file
records to database records, and after
repeatedly applying the code to each record in the file (which uses many
recordset for various reasons) the amount
of memory just goes up and up, I have checked my code and am definitly
closing all recordsets used

Is this a known problem?

Thanks in advance

replying here

Simon

the test program code follows, it was basically copied from the MSDN
help files and modified

Option Explicit
Dim cnn1 As Connection
Dim orders As Recordset
Dim inst As Recordset
Dim messages As Recordset

'*****************************************
'open connection to db
Private Sub openDB_Click()
    Dim strCnn As String
    ' Open connection.
    strCnn = "Provider=SQLOLEDB;" & _
    "Data Source=DEMOSERVER;Initial Catalog=WPD_Jocs;User
Id=sa;Password=; "
    Set cnn1 = New Connection
    cnn1.Open strCnn
End Sub

'*****************************************
Private Sub closeDB_Click()
    cnn1.Close
    Set cnn1 = Nothing
End Sub

'*****************************************
'open the orders table
Private Sub openOrders_Click()

    Set orders = New Recordset
    orders.CursorType = adOpenKeyset
    orders.LockType = adLockOptimistic
    orders.Open "Orders", cnn1, , , adCmdTable

End Sub

'*****************************************

Private Sub closeOrders_Click()
    orders.Close
    Set orders = Nothing
End Sub

'*****************************************

Private Sub openMsgs_Click()

    Set messages = New Recordset
    messages.CursorType = adOpenKeyset
    messages.LockType = adLockOptimistic
    messages.Open "Messages", cnn1, , , adCmdTable
    'MsgBox messages.Fields("MsgID").Value & ":"
End Sub

'*****************************************

Private Sub closeMsgs_Click()
    messages.Close
    Set messages = Nothing
End Sub

'*****************************************

Private Sub openInst_Click()
    Set inst = New Recordset
    inst.CursorType = adOpenKeyset
    inst.LockType = adLockOptimistic
    inst.Open "OrderInstructionList", cnn1, , , adCmdTable
End Sub

'*****************************************

Private Sub closeInst_Click()
    inst.Close
    Set inst = Nothing
End Sub



Sat, 28 Sep 2002 03:00:00 GMT  
 Possible Memory Leak When Using ADO/DAO with VB6
I would be very greateful  if anyone can help with the following:
When using DAO and ADO with VB it appears that VB does not always
release the
memory it uses for the recordset objects even after I have closed the
recordset and or set it to nothing, I wrote a little test program that
opened an ADO connection to
an SQL server 7 database and opened and closed 3 recordset objects. It
appears to
deallocate some of the memory after closing the recordsets but does not
deallocate
around 4K. so if I repeatedly open and close the recordsets the memory
allocation after it stabilises, is 4K greater, I am using NT Task
Manager to monitor the mem allocation,
I am using NT 4.0 Enterprise Edition SP6, and VB 6 (no service pack)

The main problem is I have wrote some software which converts text file
records to database records, and after
repeatedly applying the code to each record in the file (which uses many
recordset for various reasons) the amount
of memory just goes up and up, I have checked my code and am definitly
closing all recordsets used

Is this a known problem?

Thanks in advance

replying here

Simon

the test program code follows, it was basically copied from the MSDN
help files and modified

Option Explicit
Dim cnn1 As Connection
Dim orders As Recordset
Dim inst As Recordset
Dim messages As Recordset

'*****************************************
'open connection to db
Private Sub openDB_Click()
    Dim strCnn As String
    ' Open connection.
    strCnn = "Provider=SQLOLEDB;" & _
    "Data Source=DEMOSERVER;Initial Catalog=WPD_Jocs;User
Id=sa;Password=; "
    Set cnn1 = New Connection
    cnn1.Open strCnn
End Sub

'*****************************************
Private Sub closeDB_Click()
    cnn1.Close
    Set cnn1 = Nothing
End Sub

'*****************************************
'open the orders table
Private Sub openOrders_Click()

    Set orders = New Recordset
    orders.CursorType = adOpenKeyset
    orders.LockType = adLockOptimistic
    orders.Open "Orders", cnn1, , , adCmdTable

End Sub

'*****************************************

Private Sub closeOrders_Click()
    orders.Close
    Set orders = Nothing
End Sub

'*****************************************

Private Sub openMsgs_Click()

    Set messages = New Recordset
    messages.CursorType = adOpenKeyset
    messages.LockType = adLockOptimistic
    messages.Open "Messages", cnn1, , , adCmdTable
    'MsgBox messages.Fields("MsgID").Value & ":"
End Sub

'*****************************************

Private Sub closeMsgs_Click()
    messages.Close
    Set messages = Nothing
End Sub

'*****************************************

Private Sub openInst_Click()
    Set inst = New Recordset
    inst.CursorType = adOpenKeyset
    inst.LockType = adLockOptimistic
    inst.Open "OrderInstructionList", cnn1, , , adCmdTable
End Sub

'*****************************************

Private Sub closeInst_Click()
    inst.Close
    Set inst = Nothing
End Sub



Sat, 28 Sep 2002 03:00:00 GMT  
 Possible Memory Leak When Using ADO/DAO with VB6
I would be very greateful  if anyone can help with the following:
When using DAO and ADO with VB it appears that VB does not always
release the
memory it uses for the recordset objects even after I have closed the
recordset and or set it to nothing, I wrote a little test program that
opened an ADO connection to
an SQL server 7 database and opened and closed 3 recordset objects. It
appears to
deallocate some of the memory after closing the recordsets but does not
deallocate
around 4K. so if I repeatedly open and close the recordsets the memory
allocation after it stabilises, is 4K greater, I am using NT Task
Manager to monitor the mem allocation,
I am using NT 4.0 Enterprise Edition SP6, and VB 6 (no service pack)

The main problem is I have wrote some software which converts text file
records to database records, and after
repeatedly applying the code to each record in the file (which uses many
recordset for various reasons) the amount
of memory just goes up and up, I have checked my code and am definitly
closing all recordsets used

Is this a known problem?

Thanks in advance

replying here

Simon

the test program code follows, it was basically copied from the MSDN
help files and modified

Option Explicit
Dim cnn1 As Connection
Dim orders As Recordset
Dim inst As Recordset
Dim messages As Recordset

'*****************************************
'open connection to db
Private Sub openDB_Click()
    Dim strCnn As String
    ' Open connection.
    strCnn = "Provider=SQLOLEDB;" & _
    "Data Source=DEMOSERVER;Initial Catalog=WPD_Jocs;User
Id=sa;Password=; "
    Set cnn1 = New Connection
    cnn1.Open strCnn
End Sub

'*****************************************
Private Sub closeDB_Click()
    cnn1.Close
    Set cnn1 = Nothing
End Sub

'*****************************************
'open the orders table
Private Sub openOrders_Click()

    Set orders = New Recordset
    orders.CursorType = adOpenKeyset
    orders.LockType = adLockOptimistic
    orders.Open "Orders", cnn1, , , adCmdTable

End Sub

'*****************************************

Private Sub closeOrders_Click()
    orders.Close
    Set orders = Nothing
End Sub

'*****************************************

Private Sub openMsgs_Click()

    Set messages = New Recordset
    messages.CursorType = adOpenKeyset
    messages.LockType = adLockOptimistic
    messages.Open "Messages", cnn1, , , adCmdTable
    'MsgBox messages.Fields("MsgID").Value & ":"
End Sub

'*****************************************

Private Sub closeMsgs_Click()
    messages.Close
    Set messages = Nothing
End Sub

'*****************************************

Private Sub openInst_Click()
    Set inst = New Recordset
    inst.CursorType = adOpenKeyset
    inst.LockType = adLockOptimistic
    inst.Open "OrderInstructionList", cnn1, , , adCmdTable
End Sub

'*****************************************

Private Sub closeInst_Click()
    inst.Close
    Set inst = Nothing
End Sub



Sat, 28 Sep 2002 03:00:00 GMT  
 Possible Memory Leak When Using ADO/DAO with VB6
I would be very greateful  if anyone can help with the following:
When using DAO and ADO with VB it appears that VB does not always
release the
memory it uses for the recordset objects even after I have closed the
recordset and or set it to nothing, I wrote a little test program that
opened an ADO connection to
an SQL server 7 database and opened and closed 3 recordset objects. It
appears to
deallocate some of the memory after closing the recordsets but does not
deallocate
around 4K. so if I repeatedly open and close the recordsets the memory
allocation after it stabilises, is 4K greater, I am using NT Task
Manager to monitor the mem allocation,
I am using NT 4.0 Enterprise Edition SP6, and VB 6 (no service pack)

The main problem is I have wrote some software which converts text file
records to database records, and after
repeatedly applying the code to each record in the file (which uses many
recordset for various reasons) the amount
of memory just goes up and up, I have checked my code and am definitly
closing all recordsets used

Is this a known problem?

Thanks in advance

replying here

Simon

the test program code follows, it was basically copied from the MSDN
help files and modified

Option Explicit
Dim cnn1 As Connection
Dim orders As Recordset
Dim inst As Recordset
Dim messages As Recordset

'*****************************************
'open connection to db
Private Sub openDB_Click()
    Dim strCnn As String
    ' Open connection.
    strCnn = "Provider=SQLOLEDB;" & _
    "Data Source=DEMOSERVER;Initial Catalog=WPD_Jocs;User
Id=sa;Password=; "
    Set cnn1 = New Connection
    cnn1.Open strCnn
End Sub

'*****************************************
Private Sub closeDB_Click()
    cnn1.Close
    Set cnn1 = Nothing
End Sub

'*****************************************
'open the orders table
Private Sub openOrders_Click()

    Set orders = New Recordset
    orders.CursorType = adOpenKeyset
    orders.LockType = adLockOptimistic
    orders.Open "Orders", cnn1, , , adCmdTable

End Sub

'*****************************************

Private Sub closeOrders_Click()
    orders.Close
    Set orders = Nothing
End Sub

'*****************************************

Private Sub openMsgs_Click()

    Set messages = New Recordset
    messages.CursorType = adOpenKeyset
    messages.LockType = adLockOptimistic
    messages.Open "Messages", cnn1, , , adCmdTable
    'MsgBox messages.Fields("MsgID").Value & ":"
End Sub

'*****************************************

Private Sub closeMsgs_Click()
    messages.Close
    Set messages = Nothing
End Sub

'*****************************************

Private Sub openInst_Click()
    Set inst = New Recordset
    inst.CursorType = adOpenKeyset
    inst.LockType = adLockOptimistic
    inst.Open "OrderInstructionList", cnn1, , , adCmdTable
End Sub

'*****************************************

Private Sub closeInst_Click()
    inst.Close
    Set inst = Nothing
End Sub



Sat, 28 Sep 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Memory leak using ADO

2. Memory leaks using ADO 2.5

3. ADO Memory Leak results in out of memory

4. Memory growth using VB6 and DAO 3.5

5. Memory Leak in DAO Update Method

6. DAO update memory leak?

7. Memory Leak in DAO Update Method

8. Possible memory leak - error '800a0007'

9. Memory Leaking in VB Com is it possible?

10. Possible memory leak-loading/unloading forms?

11. Memory Leak in DAO Update method

12. VB6 memory leak when setting datasource

 

 
Powered by phpBB® Forum Software