[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Release Memory allocation for Datagridview

Posted on 2009-05-20
5
Medium Priority
?
338 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 1000 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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

649 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