473,395 Members | 1,411 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Garbage collector in datagridview.

Hello,
I'm using a datagridview with an inner dropdownlist for a column.
The datasource for the gridview and the dropdrownlist is a object,
with inner collection for the dropdrownlist.

When i change the datasource of both and i clear the binding of the
gridview, i call GC.Collect(), to clear my local cache. But the object
is not collected, it seem there is still a reference to it, from the
dropdownlist ...

I didn't find any databinding clear, and setting datasource to
nothing, didn't change anything.

Any idea ?

Thanks

Decco

Apr 3 '07 #1
4 1425
co*****@gmail.com wrote:
Hello,
I'm using a datagridview with an inner dropdownlist for a column.
The datasource for the gridview and the dropdrownlist is a object,
with inner collection for the dropdrownlist.

When i change the datasource of both and i clear the binding of the
gridview, i call GC.Collect(), to clear my local cache. But the object
is not collected, it seem there is still a reference to it, from the
dropdownlist ...

I didn't find any databinding clear, and setting datasource to
nothing, didn't change anything.

Any idea ?

Thanks

Decco
Never call GC.Collect. (Unless you have a really good reason and know
exactly why you are doing it.)

Forcing a collection doesn't in any way guarantee that all collectable
objects are actually collected. How did you determine that the objects
were not collected, anyway?

--
Göran Andersson
_____
http://www.guffa.com
Apr 3 '07 #2
On 3 avr, 13:47, Göran Andersson <g...@guffa.comwrote:
coco...@gmail.com wrote:
Hello,
I'm using a datagridview with an inner dropdownlist for a column.
The datasource for the gridview and the dropdrownlist is a object,
with inner collection for the dropdrownlist.
When i change the datasource of both and i clear the binding of the
gridview, i call GC.Collect(), to clear my local cache. But the object
is not collected, it seem there is still a reference to it, from the
dropdownlist ...
I didn't find any databinding clear, and setting datasource to
nothing, didn't change anything.
Any idea ?
Thanks
Decco

Never call GC.Collect. (Unless you have a really good reason and know
exactly why you are doing it.)

Forcing a collection doesn't in any way guarantee that all collectable
objects are actually collected. How did you determine that the objects
were not collected, anyway?

--
Göran Andersson
_____http://www.guffa.com- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -
I'm using a dictionnary of weakreference to those object, to make the
local cache. (it's to have less request to the DB).
So, time to time, i must clear the cache.
I call GC.collect, and after i delete from the dictonnary, the
weakreference where isAlive is false.
But i can see that they are still Alive, and the dictonnary is not
empty.

Also, when i remove the dropdown list, it work as expected, so i
deduce the dropdownlist have a reference to the object ...

do you have a better idea to make a local cache ?

Apr 3 '07 #3
co*****@gmail.com wrote:
On 3 avr, 13:47, Göran Andersson <g...@guffa.comwrote:
>coco...@gmail.com wrote:
>>Hello,
I'm using a datagridview with an inner dropdownlist for a column.
The datasource for the gridview and the dropdrownlist is a object,
with inner collection for the dropdrownlist.
When i change the datasource of both and i clear the binding of the
gridview, i call GC.Collect(), to clear my local cache. But the object
is not collected, it seem there is still a reference to it, from the
dropdownlist ...
I didn't find any databinding clear, and setting datasource to
nothing, didn't change anything.
Any idea ?
Thanks
Decco
Never call GC.Collect. (Unless you have a really good reason and know
exactly why you are doing it.)

Forcing a collection doesn't in any way guarantee that all collectable
objects are actually collected. How did you determine that the objects
were not collected, anyway?

--
Göran Andersson
_____http://www.guffa.com- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -

I'm using a dictionnary of weakreference to those object, to make the
local cache. (it's to have less request to the DB).
So, time to time, i must clear the cache.
Why do you believe that you have to clear the cache?

If you are using weak references to the objects, the objects will be
garbage collected if needed.
I call GC.collect, and after i delete from the dictonnary, the
weakreference where isAlive is false.
But i can see that they are still Alive, and the dictonnary is not
empty.
The WeakReference objects doesn't disappear just because the object that
it references is collected. The IsAlive property indicates whether the
object still exists or not. If it's false, then the object doesn't exist
any more.
Also, when i remove the dropdown list, it work as expected, so i
deduce the dropdownlist have a reference to the object ...

do you have a better idea to make a local cache ?
--
Göran Andersson
_____
http://www.guffa.com
Apr 3 '07 #4
On 3 avr, 16:16, Göran Andersson <g...@guffa.comwrote:
coco...@gmail.com wrote:
On 3 avr, 13:47, Göran Andersson <g...@guffa.comwrote:
coco...@gmail.com wrote:
Hello,
I'm using a datagridview with an inner dropdownlist for a column.
The datasource for the gridview and the dropdrownlist is a object,
with inner collection for the dropdrownlist.
When i change the datasource of both and i clear the binding of the
gridview, i call GC.Collect(), to clear my local cache. But the object
is not collected, it seem there is still a reference to it, from the
dropdownlist ...
I didn't find any databinding clear, and setting datasource to
nothing, didn't change anything.
Any idea ?
Thanks
Decco
Never call GC.Collect. (Unless you have a really good reason and know
exactly why you are doing it.)
Forcing a collection doesn't in any way guarantee that all collectable
objects are actually collected. How did you determine that the objects
were not collected, anyway?
--
Göran Andersson
_____http://www.guffa.com-Masquer le texte des messages précédents-
- Afficher le texte des messages précédents -
I'm using a dictionnary of weakreference to those object, to make the
local cache. (it's to have less request to the DB).
So, time to time, i must clear the cache.

Why do you believe that you have to clear the cache?

If you are using weak references to the objects, the objects will be
garbage collected if needed.
I call GC.collect, and after i delete from the dictonnary, the
weakreference where isAlive is false.
But i can see that they are still Alive, and the dictonnary is not
empty.

The WeakReference objects doesn't disappear just because the object that
it references is collected. The IsAlive property indicates whether the
object still exists or not. If it's false, then the object doesn't exist
any more.
Also, when i remove the dropdown list, it work as expected, so i
deduce the dropdownlist have a reference to the object ...
do you have a better idea to make a local cache ?

--
Göran Andersson
_____http://www.guffa.com- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -
The WeakReference objects doesn't disappear just because the object that
it references is collected. The IsAlive property indicates whether the
object still exists or not. If it's false, then the object doesn't exist
any more.
that's why, i check if the IsAlive is false. if it's false, i don't
need anymore the weakref in my dictionary, so i remove them.
But the IsAlive are still true, the object aren't collected. And this,
only when i use the combobox in the gridview.
Else, when i don't use de combobox, the object are collected as
expected, the isAlive go false, and i can remove the weakref from the
dictionnary.

Apr 3 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob | last post by:
Are there any known applications out there used to test the performance of the .NET garbage collector over a long period of time? Basically I need an application that creates objects, uses them, and...
10
by: pachanga | last post by:
The Hans-Boehm garbage collector can be successfully used with C and C++, but not yet a standard for C++.. Is there talks about Garbage Collector to become in the C++ standard?
5
by: Ben | last post by:
Could someone please verify if what I am doing as follow is corrected: 1. when dealing with custom class objects: ..... public myObject as myClass myObject as New myClass .......here I am...
13
by: Mingnan G. | last post by:
Hello everyone. I have written a garbage collector for standard C++ application. It has following main features. 1) Deterministic Finalization Providing deterministic finalization, the system...
28
by: Goalie_Ca | last post by:
I have been reading (or at least googling) about the potential addition of optional garbage collection to C++0x. There are numerous myths and whatnot with very little detailed information. Will...
142
by: jacob navia | last post by:
Abstract -------- Garbage collection is a method of managing memory by using a "collector" library. Periodically, or triggered by an allocation request, the collector looks for unused memory...
8
by: Paul.Lee.1971 | last post by:
Hi everyone, A program that I'm helping to code seems to slow down drastically during initialisation, and looking at the profiling graph, it seems to be the garbage collector thats slowing things...
56
by: Johnny E. Jensen | last post by:
Hellow I'am not sure what to think about the Garbage Collector. I have a Class OutlookObject, It have two private variables. Private Microsoft.Office.Interop.Outlook.Application _Application =...
46
by: Carlo Milanesi | last post by:
Hello, traditionally, in C++, dynamically allocated memory has been managed explicitly by calling "delete" in the application code. Now, in addition to the standard library strings, containers,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.