Solved

Release Memory allocation for Datagridview

Posted on 2009-05-20
5
323 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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