VS.NET 2005 / .NET 2.0 Memory Retention Problems with DataGrid

  • Thread starter Robbe Morris [C# MVP]
  • Start date
R

Robbe Morris [C# MVP]

Has anybody noticed problems with the windows forms
DataGrid not releasing memory?

I did some testing loading up a DataGrid with
5000 or so records (and yes, I need that many in the UI
at any one given time - odd I know).

If I clear the rows and columns and reload the grid, it never
releases the memory. So, after four or five times
of reloading with different groups of records, it keeps
a hold of quite a bit of memory.

My grid contains the standard datagrid textbox, checkbox,
combobox and label or text only cells. No other custom
objects or anything fancy.

Anyone experience the same issues?
 
P

PeeMore

I am experiencing the very same thing. I've tried reusing the DataSet
and I've tried Setting my DataSet = Nothing and recreated it and I
still have the same problems.

Also I have tried sending GC.Collect to force a Garbase colleciton, and
it doesn't effect my memory usage.

Another thing is under Perf Mon the Private Byte for my app keeps
increasing until eventually I get a Virtual Memory error and then
finally the application crashes due to low memory.

The machine it's running on has 1G of memory and a Paging Space of 2g.
Needless to say after refreshing the DataSet every minute, after about
3 hours I have 400mb of memory taken up, and it it runn overnight, it
just dies.

I would LOVE to know how to remedy this problem as I have read numerous
forums and still found nothing that seems to solve the issue.
 
P

PeeMore

Robbe is the data you are retreiveing pulled from a ODBC source by
chance? I did some testing and found that if I Clear my DataSet
tables, and then just add data back to them, after about a minute my
memory usage levels off. However if I call data in from my ODBC
source, it just keeps climbing. Maybe this is a problem with the ODBC
not releasing it resources?

Even if I dispose of all the ODBC Connections and DataAdapters and just
return the DataSet I populated, it still climbs.

Here is the code that causes the issue:

Public Function GetOpenRemedyTickets(ByVal dsRemedy As DataSet) As
DataSet
Dim SQLStatement As String

RemedyConnection = New Odbc.OdbcConnection
RemedyConnection.ConnectionString = "DRIVER=AR System ODBC
Driver;" & _
"UID=" &
RemedyTicketCounter.MainForm.Username & ";" & _
"PWD=" &
RemedyTicketCounter.MainForm.Passwd & ";" & _
"SERVER=NotTheServer;" & _
"ARAuthentication=;" & _
"ARServer=remedy03"

RemedySelect = New Odbc.OdbcCommand
RemedySelect.CommandText = "SELECT ""Ticket Number"", Assignee,
Severity, ""Assigned To Group"", Status " & _
"FROM
""ATS:AcxiomTechnicalServices"" " & _
"WHERE (""Assigned To Group"" IN
('PTSUNIX1','PTSUNIX2')) " & _
"AND (Status NOT IN
('Closed','Closure Pending','New'))"
RemedySelect.Connection = RemedyConnection

RemedyAdapter = New Odbc.OdbcDataAdapter
RemedyAdapter.SelectCommand = RemedySelect

If dsRemedy.Tables.Contains("OpenRemedyTickets") Then
dsRemedy.Tables("OpenRemedyTickets").Clear()
End If

RemedyAdapter.Fill(dsRemedy, "OpenRemedyTickets")

RemedyConnection.Close()
RemedyConnection.Dispose()
RemedySelect.Dispose()
RemedyAdapter.Dispose()

Return dsRemedy
End Function
 
I

Ilya Dyoshin

I have had such problem too. For my task it was unnecessary to hold old
datasets. So everytime before I add new data to my DataSet, I use

delete myDataSet;

myDataSet = gcnew System::Data::DataSet();

and it works fine!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top