.NET Garbage Collector Question - Pinned Memory

C

Crash

..Net - All versions

I have Essential .Net Vol 1 (Don Box) and the Jeffrey Richter articles
on the .NET heap - they are both excellent reads. But I am still
unclear on the big pinned memory question:

Pinned memory: if I have a block of pinned memory active on the heap
when a garbage collection occurs where does the garbage collector set
the NextObj pointer? Can the garbage collector/heap allocator logic
work around the pinned block or does the pinned block become the new
top of the heap?

Please respond to this post only if you know the articles I mentioned
and/or know the answer to my question - I don't want people to think
that this post was answered unless it has actually been answered.
Thanx in advance for anybody's help that knows what I am fishing for :)
 
N

Nicholas Paldino [.NET/C# MVP]

If you think about it, it can't be after the pinned block, because what
if the pinned block takes up the last section of memory on the heap? You
would end up getting an OOM exception when in reality you have available
memory (which the CLR does not do). The GC HAS to work around the pinned
block.

Since the CLR has to work around the pinned objects, this can easily
lead to fragmentation of the heap. Maoni blogs about this here:

http://blogs.msdn.com/maoni/archive/2005/10/03/so-what-s-new-in-the-clr-2-0-gc.aspx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top