|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Memory leaks?Hi, I have an app which connects to an Access database on a server, there
are around 10 clients. It's a fairly heavy data intensive app, but most of the traffic is look up data. While the system appears to run completely error free around every 6 weeks the server stops serving the network share where the database resides. When a client tried to connect you get an error message something like Not enough resources or disk failure. Resetting the server cleares the problem. More worrying is a large database corruption that happened just a couple of days ago. As far as I can tell my code is correct and I'm not leaving anything open or connected that shouldn't be. Is there any way to trace or track what connections and/or resources are being used by each Client? Or if my code is generating any memory leaks? Cheers, Tull. Check to see if your Access db is being opened repeatedly and never
closed, or if a large number of file locks are accumulating on it. For a Windows server, you can check here: Control Panel/Administrative Tools/Computer Management/Shared Folders/Open Files This can be a problem with Access Databases and can even cause corruption
(IMO, base on anecdotal experience). I would back this database up daily so that you don't loose too much data, in case corruption does occur. Additionally, I would compact this database often if you are doing any kind of data manipulation at all. You can do this programmatically via the JRO library. Dim src As String Dim dest As String Dim tmpDB As String Dim je As JRO.JetEngine = New JetEngineClass tmpDB = CLog.GetAppPath() & "\tmp.mdb" src = con.ConnectionString ' ADODB connection that has already been opened dest = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & tmpDB & ";Jet OLEDB:Engine Type=5" If con.State <> ADODB.ObjectStateEnum.adStateClosed Then con.Close() End If je.CompactDatabase(src, dest) Kill(m_sDBName) ' m_sDBName is the name of the database and it's location File.Move(tmpDB, m_sDBName) con.Open() je = Nothing Hope you were looking for something like this. Otherwise, sorry I posted nonsense for you. Steve Show quoteHide quote "T Clancey" <t***@idcodeware.co.uk> wrote in message news:KomdnVErmf41kbPYRVnyjA@bt.com... > Hi, I have an app which connects to an Access database on a server, there > are around 10 clients. It's a fairly heavy data intensive app, but most > of the traffic is look up data. > > While the system appears to run completely error free around every 6 weeks > the server stops serving the network share where the database resides. > When a client tried to connect you get an error message something like Not > enough resources or disk failure. Resetting the server cleares the > problem. More worrying is a large database corruption that happened just > a couple of days ago. > > As far as I can tell my code is correct and I'm not leaving anything open > or connected that shouldn't be. Is there any way to trace or track what > connections and/or resources are being used by each Client? Or if my code > is generating any memory leaks? > > Cheers, > Tull. > I think you've got a lot of unneccessary code here. All you need is this:
dim dbPath As String = (path to database here) dim conString As String = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" & dbPath dim con As New OleDB.OleDBConnection(conString) Try con.Open ...your database code here... Catch ex As OleDbException ...handle database exceptions here... Catch ex As Exception ...handle CLR exceptions here Finally con.close con.dispose End Try Notes: In ADO.NET, you can call the .Close() method of any object that has one without worrying about whether it is actually open or not. If it is open, it will close it. If it is already closed, no action is taken & no exception is thrown. You should always open your connection inside of a Try...Catch and you should always close it and dispose of it in the Try...Catch's Finally so it will always get closed and disposed, even if there are exceptions thrown along the way. Show quoteHide quote "Steve Long" <Steve_Noneya@NoSpam.com> wrote in message news:O4sfzhj7GHA.4996@TK2MSFTNGP03.phx.gbl... > This can be a problem with Access Databases and can even cause corruption > (IMO, base on anecdotal experience). I would back this database up daily > so that you don't loose too much data, in case corruption does occur. > Additionally, I would compact this database often if you are doing any > kind of data manipulation at all. You can do this programmatically via the > JRO library. > > Dim src As String > > Dim dest As String > > Dim tmpDB As String > > Dim je As JRO.JetEngine = New JetEngineClass > > tmpDB = CLog.GetAppPath() & "\tmp.mdb" > > src = con.ConnectionString ' ADODB connection that has already been > opened > > dest = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & tmpDB & ";Jet > OLEDB:Engine Type=5" > > If con.State <> ADODB.ObjectStateEnum.adStateClosed Then > > con.Close() > > End If > > je.CompactDatabase(src, dest) > > Kill(m_sDBName) ' m_sDBName is the name of the database and it's > location > > File.Move(tmpDB, m_sDBName) > > con.Open() > > je = Nothing > > Hope you were looking for something like this. Otherwise, sorry I posted > nonsense for you. > > Steve > > "T Clancey" <t***@idcodeware.co.uk> wrote in message > news:KomdnVErmf41kbPYRVnyjA@bt.com... >> Hi, I have an app which connects to an Access database on a server, there >> are around 10 clients. It's a fairly heavy data intensive app, but most >> of the traffic is look up data. >> >> While the system appears to run completely error free around every 6 >> weeks the server stops serving the network share where the database >> resides. When a client tried to connect you get an error message >> something like Not enough resources or disk failure. Resetting the >> server cleares the problem. More worrying is a large database corruption >> that happened just a couple of days ago. >> >> As far as I can tell my code is correct and I'm not leaving anything open >> or connected that shouldn't be. Is there any way to trace or track what >> connections and/or resources are being used by each Client? Or if my >> code is generating any memory leaks? >> >> Cheers, >> Tull. >> > > Hmmm, didn't know that. Thanks Scott. I guess I was just a little scardy
cat... :) S Show quoteHide quote "Scott M." <s-mar@nospam.nospam> wrote in message news:%23pUZO6l7GHA.4996@TK2MSFTNGP04.phx.gbl... >I think you've got a lot of unneccessary code here. All you need is this: > > dim dbPath As String = (path to database here) > dim conString As String = "Provider=Microsoft.JET.OLEDB.4.0;Data Source=" > & dbPath > > dim con As New OleDB.OleDBConnection(conString) > > Try > con.Open > > ...your database code here... > > Catch ex As OleDbException > ...handle database exceptions here... > Catch ex As Exception > ...handle CLR exceptions here > Finally > con.close > con.dispose > End Try > > Notes: > > In ADO.NET, you can call the .Close() method of any object that has one > without worrying about whether it is actually open or not. If it is open, > it will close it. If it is already closed, no action is taken & no > exception is thrown. > > You should always open your connection inside of a Try...Catch and you > should always close it and dispose of it in the Try...Catch's Finally so > it will always get closed and disposed, even if there are exceptions > thrown along the way. > > > "Steve Long" <Steve_Noneya@NoSpam.com> wrote in message > news:O4sfzhj7GHA.4996@TK2MSFTNGP03.phx.gbl... >> This can be a problem with Access Databases and can even cause corruption >> (IMO, base on anecdotal experience). I would back this database up daily >> so that you don't loose too much data, in case corruption does occur. >> Additionally, I would compact this database often if you are doing any >> kind of data manipulation at all. You can do this programmatically via >> the JRO library. >> >> Dim src As String >> >> Dim dest As String >> >> Dim tmpDB As String >> >> Dim je As JRO.JetEngine = New JetEngineClass >> >> tmpDB = CLog.GetAppPath() & "\tmp.mdb" >> >> src = con.ConnectionString ' ADODB connection that has already >> been opened >> >> dest = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & tmpDB & ";Jet >> OLEDB:Engine Type=5" >> >> If con.State <> ADODB.ObjectStateEnum.adStateClosed Then >> >> con.Close() >> >> End If >> >> je.CompactDatabase(src, dest) >> >> Kill(m_sDBName) ' m_sDBName is the name of the database and it's >> location >> >> File.Move(tmpDB, m_sDBName) >> >> con.Open() >> >> je = Nothing >> >> Hope you were looking for something like this. Otherwise, sorry I posted >> nonsense for you. >> >> Steve >> >> "T Clancey" <t***@idcodeware.co.uk> wrote in message >> news:KomdnVErmf41kbPYRVnyjA@bt.com... >>> Hi, I have an app which connects to an Access database on a server, >>> there are around 10 clients. It's a fairly heavy data intensive app, >>> but most of the traffic is look up data. >>> >>> While the system appears to run completely error free around every 6 >>> weeks the server stops serving the network share where the database >>> resides. When a client tried to connect you get an error message >>> something like Not enough resources or disk failure. Resetting the >>> server cleares the problem. More worrying is a large database >>> corruption that happened just a couple of days ago. >>> >>> As far as I can tell my code is correct and I'm not leaving anything >>> open or connected that shouldn't be. Is there any way to trace or track >>> what connections and/or resources are being used by each Client? Or if >>> my code is generating any memory leaks? >>> >>> Cheers, >>> Tull. >>> >> >> > >
Make application sleep
file transfer help? anyway to unload the dll mp3 synchronised lyrics Programmatically Find All Registry Entries Bitmap to JPEG with compression settings Design View when using an ASP:Panel to show/hide groups of <tr>'s Get EXIF data from picture Passing 2-D Array from one function to another Calculator |
|||||||||||||||||||||||