Re: life-time pinning. vs Global heap

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Yes of course.

I attempted to imply that the gc doesn't try very often
to move large objects so the gc performance penelty
for pinnin will be reduced.

Thanks again.


"Chris Mullins [MVP - C#]" wrote:

Don't assume that because the LOH isn't compacted today, that it won't be in
the future.

Be sure to pin whatever you allocate, so that you're future proof. It would
suck to have a customer installed a Service Pack, and have your app break.

--
Chris

"TheMadHatter" <TheMadHatter@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F4115F14-5045-41F6-A3FB-2FDC4E82D727@xxxxxxxxxxxxxxxx
Thanks Chris.
I didnt know about the ArraySegment<T> :D

Oh yea... and the Large Object Heap.....
It has a tendency not to move objects as well. humm.....

Once again thanks for the insightful answer. :) :) :)

"Chris Mullins [MVP - C#]" wrote:

My personal experience is that the best bet is to:
- Allocate a big byte array at the start of your program. This ends up
coming out of the Large Object Heap.
- Pin the array using the GC Handle.
- use ArraySegment<T> to partition the big array during the lifetime of
your
app...

--
Chris Mullins

"TheMadHatter" <TheMadHatter@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:68646A13-E464-44E2-975A-D2445D163828@xxxxxxxxxxxxxxxx

I am very sorry to bring a topic up that has been beaten with an ugly
stick..... but...

If I want to "fix" an byte array for the life time of a program would
it
be
better allocating it on the unmanaged heap?

Yes I know that if I am to pin the object for long periods of time,
that
it
would be best to do it at the very initial start of the program so that
it
prevents some fragmentation of the managed heap.

Thanks in advance for your thoughts on the matter.






.



Relevant Pages

  • Re: segfault with large-ish array with GNAT
    ... specifically) would be smart enough to allocate memory for large ... using pointers (and thus take the memory from the heap). ... the array is not in the heap in this case; ...
    (comp.lang.ada)
  • Re: life-time pinning. vs Global heap
    ... Be sure to pin whatever you allocate, ... coming out of the Large Object Heap. ... Pin the array using the GC Handle. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: life-time pinning. vs Global heap
    ... coming out of the Large Object Heap. ... Pin the array using the GC Handle. ... If I want to "fix" an byte array for the life time of a program would it ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: A simple ADA puzzle (I havent the answer)
    ... > this type declaration would be to always allocate objects of this type off ... > of a heap, so that sizes could be adjusted as needed. ... That works better when you have multiple array ...
    (comp.lang.ada)
  • Re: life-time pinning. vs Global heap
    ... - Allocate a big byte array at the start of your program. ... coming out of the Large Object Heap. ... Pin the array using the GC Handle. ... If I want to "fix" an byte array for the life time of a program would it ...
    (microsoft.public.dotnet.languages.csharp)