Home > Net >  C # of garbage collection, timing, how do you determine the size? Can be configured manually?
C # of garbage collection, timing, how do you determine the size? Can be configured manually?

Time:10-05

RT
Just change your job, soon turned to c #, a program, based on the analysis of data,
Task manager to see the program in memory up to more than 300 M of memory, the memory will descend to 200 M, and then rose to more than 300 M down again after more than 200 M, the cycle...

Boss (not a professional to do procedure, how many know something, ask me memory usage can fall down, when he asked me why I go up more than 100 M will be recycled, why to recycle more than 100 M, not more than 200 M,
I received all of a sudden, he said only a dynamically allocated memory recovery depends on the GC on the specific time not sure recycling and size...
He said some to domestic entities enough, can't let the GC to make it...


So to ask everyone: GC recycling memory is how to determine the timing and size? Can your configuration?

Any explanation, materials, articles, links are welcome, thank you first!!











CodePudding user response:

You hand the Dispose or destructor,

CodePudding user response:

reference 1st floor is nu month god reply:
that you manually Dispose or destructor,

Memory is mainly the application release more frequently, I personally think, frequent application free memory and to get a memory pool, it is better to directly make the GC management is more convenient for me...

CodePudding user response:

Do you want to have enough control internally, in c + +, all his control,

Or open a thread, to monitor process usage, more than a threshold 250 m, for example, forced to GC. Conlect ()

CodePudding user response:

No dice, garbage collection mechanism is not so easy to use code that.

You can test.

A collection has been add to the tens of thousands of hundreds of thousands of variables.

Then you in to his assignment null or clear do you have any changes in the memory.

Or manual GC, you look at the effect.

CodePudding user response:

refer to the second floor CCDDzclxy response:
Quote: refer to 1st floor is nu month god reply:

That you manually Dispose or destructor,

Memory is mainly the application release more frequently, I personally think, frequent application free memory and to get a memory pool, it is better to directly make the GC management is more convenient for me...

The emergence of GC,
Is to let programmers don't care about the release of memory problems,,,

CodePudding user response:

Garbage collection mechanism inside have their own judgment, would like to go to the configuration manually, it is not too realistic,
Give you recommend a book to see,
"CLR via c # (fourth edition)" chapter 21 managed heap and recycling has a very detailed description,

CodePudding user response:

reference 5 floor is nu month god reply:
Quote: refer to the second floor CCDDzclxy response:

Quote: refer to 1st floor is nu month god reply:

That you manually Dispose or destructor,

Memory is mainly the application release more frequently, I personally think, frequent application free memory and to get a memory pool, it is better to directly make the GC management is more convenient for me...

The emergence of GC,
Is to let programmers don't care about the release of memory problems,,,

Is ah, ah I low-level employees to serve master not easy ah

CodePudding user response:

C # is usually automatically collect, you need to do is put your use variables to empty, the system will automatically processing, local variables within the function need not worry about, the function need not tube

CodePudding user response:

Compulsory recycling can call GC. Collect ()
But the vast majority of cases, there is no need to manually do the 300 m memory footprint is not a big deal

CodePudding user response:

Dogs with mouse

CodePudding user response:

The gc is not dealt with, and if you want to just your hand release
  •  Tags:  
  • C#