Solved

Release Memory allocation for Datagridview

Posted on 2009-05-20
5
315 Views
Last Modified: 2012-05-07
Hi,

I have a datagridview populated with data. I would like to be able to clear the dataand release the memory alocated for that data with a reset switch. The data in the grid isnt bound when I create the grid I create the columns and the data.

Using VB.NET 2005

Michal
0
Comment
Question by:MichMat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
oobayly earned 250 total points
ID: 24429877
The garbage collector should clean up any unused objects. However you need to make sure that any references to the data are no longer used.
You can forcibly can call Collect on the Garbage Collector.
GC.Collect()

Open in new window

0
 
LVL 48

Assisted Solution

by:jpaulino
jpaulino earned 250 total points
ID: 24429885
If you want to clear the columns/rows you can use:

Me.DataGridView1.Rows.Clear()
Me.DataGridView1.Columns.Clear()

' If you have datasource
Me.DataGridView1.DataSource = Nothing
But you don't need to clean the memory because the CLR will do that for you using the Garbage Collector. If you want to force the GC to work you can use:

GC.Collect()
GC.WaitForPendingFinalizers()
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24429890

So slow this morning ... I have to warm up better :)
0
 
LVL 15

Expert Comment

by:oobayly
ID: 24429919
I know the feeling :-) It's a more detailed answer though.
0
 

Author Closing Comment

by:MichMat
ID: 31583404
THank you both
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Open a link in vb.net 2 27
Need help with a query 14 39
VB.NET System.NullReferenceException 1 24
.Net remove carriage returns, line feeds and tabbs 5 16
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question