tagged [garbage-collection]

What are pinned objects?

What are pinned objects? I am trying to find a memory leak using ants memory profiler, and I've encountered in a new term: Pinned objects. Can some one give me a good & simple explanation about what t...

22 Mar at 09:1

Is the garbage collector in .net system-wide or application-wide?

Is the garbage collector in .net system-wide or application-wide? During discussion with my collegue, I got a doubt that the garbage collector in .net works system wide or application wide. Means if e...

14 Oct at 22:5

Does .NET have something similar to Java's garbage collection log?

Does .NET have something similar to Java's garbage collection log? Does .NET have something similar to Java's garbage collection log? I want to write GC stats to a log in a production application. Goo...

22 Jul at 21:53

When will an object declared in a static class get garbage collected?

When will an object declared in a static class get garbage collected? When will the `Class1` instance `obj` in `stClass` get garbage collected, if i am calling the static function `stClass.returnSomet...

11 Dec at 04:16

C# Explicitly Removing Event Handlers

C# Explicitly Removing Event Handlers I was wondering if setting an object to null will clean up any eventhandlers that are attached to the objects events... e.g. etc... Will this cause a memory leak?

Best way to dispose a list

Best way to dispose a list I am having List object. How can I dispose of the list? For example, If I set `userCollection = null;` what will happen? Which one is best?

16 Feb at 14:3

How does garbage collection collect self-referential objects?

How does garbage collection collect self-referential objects? If an object is not referenced by any other, then it is subject to be collected by the .NET CLR garbage collector. However, if `objA` refe...

13 Dec at 12:36

Is this all for Garbage Collection in Objective-C?

Is this all for Garbage Collection in Objective-C? Hi I just picked up Obj-C and quite dislike its manual memory management. I decide to go with its Garbage Collection, by adding in my Main() and chan...

Where Is Machine.Config?

Where Is Machine.Config? I want to apply a change so That I can use Server GC settings for my C# 3.5 app - I can do that by editing the `machine.config` file. The only problem is I do not know where t...

18 Mar at 10:51

Short-lived objects

Short-lived objects What is the overhead of generating a lot of temporary objects (i.e. for interim results) that "die young" (never promoted to the next generation during a garbage collection interva...

Call garbage collect in visual studio

Call garbage collect in visual studio Is it possible, to say the gc to collect during debugging session via Visual Studio 2015 Enterprise? I want to observe the memory usage of my application when cal...

Is it possible to create an "Island of Isolation" scenario in .NET?

Is it possible to create an "Island of Isolation" scenario in .NET? I have been reading about garbage collection and came to know the term "Island Of Isolation", such as when ObjectA references to Obj...

18 May at 14:30

How free memory used by a large list in C#?

How free memory used by a large list in C#? I have a list called `Population`, is a great list of very many positions and at some point I stop using it. How I can free the resources? Then this is part...

31 Jul at 00:31

Do event handlers stop garbage collection from occurring?

Do event handlers stop garbage collection from occurring? If I have the following code: Will pClass be garbage collected? Or will it hang around still firing its events whenever they occur? Will I nee...

Unloading the Assembly loaded with Assembly.LoadFrom()

Unloading the Assembly loaded with Assembly.LoadFrom() I need to check the time amount to run GetTypes() after loading the dll. The code is as follows. I'd like to unload and reload the dll to check t...

6 Jun at 21:21

How can I enable Server GC in .NET Core?

How can I enable Server GC in .NET Core? I have a .NET Core app () developed in running on the version of the . I have tried adding an `App.config` with the following entries: Which on build is rename...

17 May at 21:47

How does the GC update references after compaction occurs

How does the GC update references after compaction occurs The .NET Garbage Collector collects objects (reclaims their memory) and also performs memory compaction (to keep memory fragmentation to minim...

19 May at 22:3

Static disposable objects

Static disposable objects - How should I manage `static` classes with disposable items? Are there any rules of thumb? - Basically, should I refactor and make the following `DisposableDataManager` clas...

C# - Are objects immediately destroyed when going out of scope?

C# - Are objects immediately destroyed when going out of scope? Can I trust that an object is destroyed and its destructor is called immediately when it goes out of scope in C#? I figure it should sin...

26 Sep at 09:45

Best Practice for Forcing Garbage Collection in C#

Best Practice for Forcing Garbage Collection in C# In my experience it seems that most people will tell you that it is unwise to force a garbage collection but in some cases where you are working with...

24 Oct at 13:49

Garbage collector problem in C#

Garbage collector problem in C# In C# code, I have three objects , and . and each hold a reference to . When is destroyed I would like the reference from to to be deleted as well so that can be destro...

29 Jan at 16:58

Special case lifetime analysis

Special case lifetime analysis Suppose I have At (1), is the object `bar` is pointing to for garbage collection? Or does `bar` have to fall out of scope as well? Does it make a difference if `GC.Colle...

13 Jul at 22:5

C#: Notification before WeakReference is collected?

C#: Notification before WeakReference is collected? In C#/.NET, is there any way to get a notification before the object pointed to by a weak reference is destructed? Basically, I want to allow an obj...

How to use GC.KeepAlive() and for what purpose?

How to use GC.KeepAlive() and for what purpose? How can we use [GC.KeepAlive()](https://learn.microsoft.com/en-us/dotnet/api/system.gc.keepalive) and what is the purpose? I transfer files from termina...

29 Jun at 08:31

Long running process suspended

Long running process suspended I have a .NET 2.0 console application running on a Windows Server GoDaddy VPS in the Visual Studio 2010 IDE in debug mode (F5). The application periodically freezes (as ...