Linked Questions
32 questions linked to/from What's so wrong about using GC.Collect()?
204 votes
11 answers
292k views
How to force garbage collector to run?
Interviewer asked me about this today ...is there an answer ?
127 votes
17 answers
171k views
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 large objects that don't always get collected in ...
74 votes
4 answers
38k views
Parallel.ForEach can cause a "Out Of Memory" exception if working with a enumerable with a large object
I am trying to migrate a database where images were stored in the database to a record in the database pointing at a file on the hard drive. I was trying to use Parallel.ForEach to speed up the ...
34 votes
11 answers
119k views
How to delete an array in c#?
I'm sorry if this is an obvious question but neither Google or a search here led me to an answer. Is there a way to remove an array entirely? I want the opposite of int[] array = new int[5]
20 votes
4 answers
24k views
Run garbage collector from command line? [closed]
Is it possible to run .NET garbage collector from command line, e.g. without writing code? Edit: When asked this question, I meant exactly what asked here for Java garbage collector: How to request ...
14 votes
6 answers
35k views
How do I get the Process ID from a created "Excel.Application" object?
How do I get the Process ID from a running object? Dim xlApp As Object = CreateObject("Excel.Application") I need to use late binding because I can't guarantee which version I will get so using ...
8 votes
9 answers
4k views
Use of Garbage Collection?
I want to know what action is performed when we call Dispose() method. Is Object frees all resources quickly on Dispose() call or Dispose() marks the Object is ready for garbage collection. And What ...
2 votes
4 answers
5k views
Call GC.Collect Before Throwing OutOfMemoryException
Is there any way to get GC.Collect() to be called before throwing an OutOfMemoryException? I suppose I'm looking for a way for it to do the following code flow: Try to Allocate Memory On Pass Return ...
4 votes
2 answers
8k views
Entity data querying and memory leak
I am downloading a lot of data in a loop but after some operations I remove them but what I see is that memory allocation is growing really fast, few seconds and 1GB, so how can clean after each ...
1 vote
6 answers
1k views
Is there a common practice how to make freeing memory for Garbage Collector easier in .NET?
I've been thinking if there's a way how to speed up freeing memory in .NET. I'm creating a game in .NET (only managed code) where no significant graphics is needed but still I would like to write it ...
4 votes
3 answers
2k views
Why is killing the Excel process a bad thing?
I've seen a lot of articles and questions about how to be sure that Excel actually quits when you want it to and the process doesn't stay alive. Here is a knowledge Base article describing the problem ...
1 vote
3 answers
7k views
How to end excel.exe process?
i m trying to get excel sheet-name of a excel file from vb.net 3.5 however it opens but excel.exe still remains in the process. How do i stop the process without killing the excel.exe from task ...
4 votes
1 answer
3k views
C# Proper Way to Close Multiple Excel Objects With Excel Process Destroyed
I have a C# console program. When it runs, it instantiates some Excel objects such as: (openExcelO). When the program is done running, I have a method to close down Excel (closeExcel) and that is ...
3 votes
3 answers
1k views
Does the Garbage Collector benefit from multiple calls to Collect and WaitForPendingFinalizers()?
I found this code online that is appended after deinitializing Excel Interop objects: GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); GC.WaitForPendingFinalizers(); Is this quasi-violation ...
0 votes
4 answers
2k views
Tips on Dealing with Large Strings With Regards to Memory Usage
How can I force a shrink of a DataTable and/or List so that I can free memory efficiently? I am currently removing the processed row from the DataSet every iteration of the loop, but I'm not sure if ...