Controling The GC

  • Thread starter Thread starter Rob Lowney
  • Start date Start date
R

Rob Lowney

Is there any way to tell .NET to "Wake up" the GC when available memory
reaches a set threshold?

Regards,

Rob.
 
no, because disposal is non-deterministic. you would have to write logic in
there to monitor memory and at the threshold, call the collect method on the
gc static object.

non-deterministic is really a misnomer in my opinion. gc runs
deterministically when generation zero is full.
 
Thanks for Alvin and Kristofer's response.

Hi Rob,

Thank you for posting in the community!

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need the GC to collect managed heap
when memory reaches a specified threshold. If there is any
misunderstanding, please feel free to let me know.

As far as I know, GC will automatically collect unreferenced memory blocks
when memeory reaches a certain limitation. However, we cannot set that
certain limitation value. Or just as Alvin said, we have to write code to
monitor memory and call GC.Collect when memory reaches that threshold.

Does this answer your question? If anything is unclear, please feel free to
reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
That is what I thought.

I know that the GC has its own threshold for available memory before it
"takes out the trash" I was just wondering if there was a config setting
somewhere that I can change easily. (ie collect garbage when 1 GB of RAM is
free)

Rob.
 
Hi Rob,

As far as I know, there isn't such a way to change the threshold. The
threshold in the .NET framework is transparent to the users. So we cannot
change it by configuration.

If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top