Delete a very large object in C #

helicopter. I'm new to C #, and I got a big picture with GC removing objects that cannot be reached by my code. The problem is that I work with some large (7-40 MB) objects, it’s good that I don’t need all at once, is this any possible way to delete an object? I tried this:

- create big object X
- use big object X
  X = null; /*so I don't have any referance to it any more*/
  GC.Collect();
  GC.WaitForPendingFinalizers(); - create next big object ....`

Does this guarantee that the large object will be deleted after exiting GC.WaitForPendingFinalizers();?

I know that I have to implement my design in order to make objects smoother, but believe me, I tried, and this complicates the logic. If there is no other way, I will do it, the code will be 2 or 3 times larger.

thank!

+3
source share
5 answers

. GC.Collect . , , . , , . , , , , . .

+16

, 100% , , .
GC , GC.Collect .
, . GC.Collect , , ! , GC , .

+1

GC.Collect . , 1, .

.NET Microsoft ( > 84 , ), . , , , , ( .NET .NET).

: http://msdn.microsoft.com/en-us/magazine/cc534993.aspx

+1

a () - (, ). (). ; , GC - ( GC).

, , - - ; , . , .

"" ; GC; , .

, , , /, , " " (LOH). LOH , . , 1000 1000 ( ) 1,000,000 - YMMV.

+1

: ? ?

0

All Articles