Hi,
I'm wondering if the GC.Collect method really collects all objects
possible objects? Or is this still a "smart" process sometimes keeping
objects alive even if they can be garbage collected?
I need to know because I'm looking for memory leaks in an application.
It would be really helpful to be able to determine if an object after
manually invoking the GC.Collect is only kept alive because it still
being referenced by other alive objects in contrast to being alive
because the GC.Collect didn't found it necessary to collect the object,
even when asked explicitly.
Regards,
Ward 48 5596
On 19 Apr, 11:37, Ward Bekker <wDotbekker@Rem oveThisequanimi tyDotnl>
wrote:
Hi,
I'm wondering if the GC.Collect method really collects all objects
possible objects? Or is this still a "smart" process sometimes keeping
objects alive even if they can be garbage collected?
I need to know because I'm looking for memory leaks in an application.
It would be really helpful to be able to determine if an object after
manually invoking the GC.Collect is only kept alive because it still
being referenced by other alive objects in contrast to being alive
because the GC.Collect didn't found it necessary to collect the object,
even when asked explicitly.
Regards,
Ward
I believe it attempts to reclaim all objects. If you've got a memory
leak though you might want to take a look at the CLR profiler http://www.microsoft.com/downloads/d...displaylang=en
thats for 1.1, there's a link for 2.0 at the bottom..
Ward,
Using GC.Collect to attempt to identify memory leaks is not a realistic
solution. Memory Leaks are generally caused by developers. Especially when
they fail to dispose of objects that need to be disposed, or if they fail to
implement similar patterns on their own objects where necessary.
There are a number of memory profilers you can use to track down this type
of issue. As well, FXCop can help you to identify bad coding patterns.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Ward Bekker" wrote:
Hi,
I'm wondering if the GC.Collect method really collects all objects
possible objects? Or is this still a "smart" process sometimes keeping
objects alive even if they can be garbage collected?
I need to know because I'm looking for memory leaks in an application.
It would be really helpful to be able to determine if an object after
manually invoking the GC.Collect is only kept alive because it still
being referenced by other alive objects in contrast to being alive
because the GC.Collect didn't found it necessary to collect the object,
even when asked explicitly.
Regards,
Ward
Let me explain a bit more. I am using a memory profiler, and see several
live objects that should be collected at the time I created a memory
snapshot.
I need to be sure that they are _really_ live objects because of a
mistake in our own code, or that they just alive because the GC.Collect
can't be trusted.
Peter Bromberg [C# MVP] wrote:
Ward,
Using GC.Collect to attempt to identify memory leaks is not a realistic
solution. Memory Leaks are generally caused by developers. Especially when
they fail to dispose of objects that need to be disposed, or if they fail to
implement similar patterns on their own objects where necessary.
There are a number of memory profilers you can use to track down this type
of issue. As well, FXCop can help you to identify bad coding patterns.
Peter
Ward Bekker wrote:
Hi,
I'm wondering if the GC.Collect method really collects all objects
possible objects? Or is this still a "smart" process sometimes keeping
objects alive even if they can be garbage collected?
I need to know because I'm looking for memory leaks in an application.
I think you will find the following article useful and interesting: http://support.microsoft.com/kb/318263/en-us
"Because of the garbage collection package that is implemented in the
Microsoft .NET Framework, it is not possible to have a memory leak in
managed code. This suggests two questions: How then can a memory leak occur?
Why does it appear that you have a memory leak?"
--
Thank you,
Christopher Ireland
Hi Cristopher,
My definition of a memory leak for managed frameworks:
All objects that should be garbage collected, but can't because they are
still referenced by other objects that will not be garbage collected ;-)
Christopher Ireland wrote:
Ward Bekker wrote:
>Hi,
I'm wondering if the GC.Collect method really collects all objects possible objects? Or is this still a "smart" process sometimes keeping objects alive even if they can be garbage collected?
I need to know because I'm looking for memory leaks in an application.
I think you will find the following article useful and interesting: http://support.microsoft.com/kb/318263/en-us
"Because of the garbage collection package that is implemented in the
Microsoft .NET Framework, it is not possible to have a memory leak in
managed code. This suggests two questions: How then can a memory leak
occur? Why does it appear that you have a memory leak?"
Ward Bekker wrote:
My definition of a memory leak for managed frameworks:
All objects that should be garbage collected, but can't because they
are still referenced by other objects that will not be garbage
collected ;-)
The article I quoted suggests to me that there are no managed objects that
can't be garbage collected!
--
Thank you,
Christopher Ireland
"Christophe r Ireland" <ci******@gmail .comschrieb im Newsbeitrag
news:3B******** *************** ***********@mic rosoft.com...
"Because of the garbage collection package that is implemented in the
Microsoft .NET Framework, it is not possible to have a memory leak in
managed code. This suggests two questions: How then can a memory leak
occur? Why does it appear that you have a memory leak?"
Though garbage collection is very usefull to provent memory leaks, this
quote is a bit to optimistic. Sure ther can be memory leaks in managed code.
E.g. all static fields aren't collected. So any object directly or
indirectly referenced by a static field wouldn't be collected. Also any
variables very high in the call stack can prevent referenced object from
being collected, (though the lifetime of a variable can be shortened by the
compiler.)
By this a memory leak in managed code can easily construckted.
But it's very unlikely to happen in real code. And it's much 'harder' to do
it purposelessly in managed code, than in unmanaged colde.
Regards
Christof
Christof Nordiek wrote:
Though garbage collection is very usefull to provent memory leaks,
this quote is a bit to optimistic. Sure ther can be memory leaks in
managed code. E.g. all static fields aren't collected. So any object
directly or indirectly referenced by a static field wouldn't be
collected. Also any variables very high in the call stack can prevent
referenced object from being collected, (though the lifetime of a
variable can be shortened by the compiler.)
By this a memory leak in managed code can easily construckted.
Interesting. Are you suggesting that the Microsoft Article 318263 I posted a
link to is somehow incorrect or misleading? Do you have any Microsoft links
which specifically refer to memory leaks in managed code?
This is an important area for me to clear up with my clients and I would
appreciate being able to quote Microsoft sources.
--
Thank you,
Christopher Ireland
Ward,
That's the thing though, if the object that you think should be garbage
collected is referenced by another object which is rooted (meaning you are
holding onto it some other way) and so on, then your object should NOT be
garbage collected. This is well-defined behavior for GC systems.
If you feel that your object should be collected at any time, then what
you really want are weak references. Take a look at the WeakReference
class.
Also, remember, if you have a delegate that points to a method on an
instance, then that instance is not eligible for GC. So if you subscribed
to an event, and didn't unsubscribe, then that instance is going to live on
as long as the object that publishes the event lives. A lot of developers
forget about this.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"Ward Bekker" <wDotbekker@Rem oveThisequanimi tyDotnlwrote in message
news:eS******** ******@TK2MSFTN GP05.phx.gbl...
Hi Cristopher,
My definition of a memory leak for managed frameworks:
All objects that should be garbage collected, but can't because they are
still referenced by other objects that will not be garbage collected ;-)
Christopher Ireland wrote:
>Ward Bekker wrote:
>>Hi,
I'm wondering if the GC.Collect method really collects all objects possible objects? Or is this still a "smart" process sometimes keeping objects alive even if they can be garbage collected?
I need to know because I'm looking for memory leaks in an application.
I think you will find the following article useful and interesting: http://support.microsoft.com/kb/318263/en-us
"Because of the garbage collection package that is implemented in the Microsoft .NET Framework, it is not possible to have a memory leak in managed code. This suggests two questions: How then can a memory leak occur? Why does it appear that you have a memory leak?" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: rmm |
last post by:
Here's a first attempt at trusted python. I would be grateful if any
python gurus could point out the, no doubt obvious, flaws.
I've stopped fileobject working with patches to fileobject and
frameobject. All child frames of the first 'trusted' frame are trusted
(checked using inspect.getouterframes(inspect.currentframe()). Trusted
is a one-way switch.
Is there anything I'm missing about the python frame structure?
Is there any way of...
|
by: David N. |
last post by:
Hi All,
I have a C# project that was created using VS.NET 2003. The project is on a shared network drive. When I open the project using VS.NET, I got the following warning message:
"The project locatoin is not fully trusted by the .Net run time because it is either a network share or mapped to a network share not on the local machine. If the output path is under the project location, your code will not execute as fully trusted and you...
|
by: Ammar |
last post by:
I've defined a linked ADSI server and I seem to be able to query the
local domain ( localdomain.com ) with:
DBCC TRACEON(7300)
GO
SELECT * FROM OPENQUERY(ADSI, 'SELECT displayName FROM
''LDAP://DC=localdomain,DC=com'' ')
But I also have a trusted domain ( trusteddomain.com ) which I would
also like to query from the same SQL-enviroment but this does not work
|
by: DMS |
last post by:
am new to ASP.NET and IIS web applications, but not to
SQL databases. I can successfully build Windows apps using
Visual Studio that use ADO. However, for Web Forms, I
created data connection and sqladapter to my SQL Server -
Northwind - which I dragged from Server Explorer. I
generate a dataset, and Preview Data in the da, works
fine. I then enter vb code on Page_Load event:
SqlDataAdapter1.Fill(ds)
DataGrid1.DataSource =...
|
by: Robert McClenon |
last post by:
I would like to know how to turn off the annoying warning about macros
in a database.
I maintain two databases on my home computer for my own use. Now that
I am using Microsoft Access 2003, every time that I open either of
them, I get the prompt "Security Warning" that says that the .mdb file
may not be safe.
In reading the Help file, it says that this message will not be
displayed if the author or corporation is on the list of...
| |
by: Frank Rizzo |
last post by:
I understand the basic premise: when the object is out of scope or has
been set to null (given that there are no funky finalizers), executing
GC.Collect will clean up your resources.
So I have a basic test. I read a bunch of data into a dataset by using
a command and a data adapter object, .Dispose(ing) as I go. The moment
the data is in the Dataset, the Mem Usage column in the Task Manager
goes up by 50 MB (which is about right). I...
|
by: Mrinal Kamboj |
last post by:
Hi ,
Any pointers when it's absolute necessary to use it .
Does it has a blocking effect on the code , as GC per se is
undeterministic .
what if GC.collect is followed in next line by
GC.WaitForPendingFinalizers , will it actually block .
|
by: Ray Valenti |
last post by:
I am able to preview this data in the development environment, but when I
run the application the error below shows up.
How do I set up a Trusted Connection?
-Ray
Server Error in '/WebApplication2' Application.
----------------------------------------------------------------------------
----
|
by: petergjansen |
last post by:
Hi,
How can I access the trusted sites list for the currently logged in
user programmatically? Is there some sort of IE API which I can call
to get this information or is it stored in a file anywhere? I need to
write a program which checks if certain sites are in a users list of
trusted sites and if not prompt them to add the sites. This is for use
with some browser based order system which are users use and they often
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |