Windows Vista Forums

SqlBulkcopy memory leak problem

  1. #1


    Sergey Zenyuk Guest

    SqlBulkcopy memory leak problem

    In VB.net windows application I use following
    code implementing SqlBulkCopy import:
    Using connODBC As New OdbcConnection(ConnStrODBC)
    connODBC.Open()
    Dim dbcmd As New OdbcCommand(String.
    Format("select * from {0}", TableName), connODBC)
    dbcmd.CommandTimeout = SQL_TIMEOUT
    bulkcopy.WriteToServer(dbcmd.ExecuteReader())
    connODBC.Close()
    connODBC.Dispose()
    End Using



    with connection string:
    Dim connbuilderODBC As New OdbcConnectionStringBuilder()
    connbuilderODBC("Driver") = "{Microsoft Visual FoxPro
    Driver}"
    connbuilderODBC("SourceType") = "DBF"
    connbuilderODBC("SourceDB") = Path.
    GetDirectoryName(DBFileName)
    connbuilderODBC("Exclusive") = "No"
    ConnStrODBC = connbuilderODBC.ConnectionString

    this code leak to memory leak problems on big files.
    After visual studio closing memory is busy.
    Please,help

      My System SpecsSystem Spec

  2. #2


    Jani Järvinen [MVP] Guest

    Re: SqlBulkcopy memory leak problem

    Hi Sergey,

    > In VB.net windows application I use following
    > code implementing SqlBulkCopy import:
    > Using connODBC As New OdbcConnection(ConnStrODBC)
    > connODBC.Open()
    > Dim dbcmd As New OdbcCommand(String.
    > Format("select * from {0}", TableName), connODBC)
    > dbcmd.CommandTimeout = SQL_TIMEOUT
    > bulkcopy.WriteToServer(dbcmd.ExecuteReader())
    > connODBC.Close()
    > connODBC.Dispose()
    > End Using
    > this code leak to memory leak problems on big files.
    How are you measuring the memory usage and leaking? One thing that is most
    probably the major factor is that you let the .NET garbage collector to
    collect memory for the OdbcCommand, OdbcDataReader and the SqlBulkCopy
    instances.

    All these implement the IDisposable interface, so you should call their
    Dispose methods if you want to make sure the memory is freed as soon as
    possible. If you don't this, you might observe the said leak.

    --
    Regards,

    Mr. Jani Järvinen
    C# MVP
    Vantaa, Finland
    janij@xxxxxx
    http://www.saunalahti.fi/janij/



      My System SpecsSystem Spec

SqlBulkcopy memory leak problem

Similar Threads
Thread Thread Starter Forum Replies Last Post
Vista Sp1 Memory Leak problem Coolvibes Vista General 10 22 Mar 2009
Memory Leak problem with AUDIODG.EXE ! Need help nullzero Sound & Audio 3 03 Dec 2008
Memory leak problem using sqlBulkCopy SteveB .NET General 0 05 Nov 2008
Memory Leak? mmajchrowicz@gmail.com Aero 1 14 Oct 2007
Memory leak Kyaw Vista General 8 22 Feb 2007