Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - SqlBulkcopy memory leak problem

Reply
 
Old 11-05-2008   #1 (permalink)
Sergey Zenyuk


 
 

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
Old 11-05-2008   #2 (permalink)
Jani Järvinen [MVP]


 
 

Re: SqlBulkcopy memory leak problem

Hi Sergey,
Quote:

> 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
Reply

Thread Tools


Similar Threads
Thread Forum
Vista Sp1 Memory Leak problem Vista General
Memory Leak problem with AUDIODG.EXE ! Need help Sound & Audio
Memory leak problem using sqlBulkCopy .NET General
Memory Leak General Discussion
Memory leak Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46