Oops, sorry for the confusion....
I am using the array in an unsafe context. (via pointers.)
I do not want to continuously use the fixed(byte* ptr = myArray) statement,
so that leaves pinning via GCHandle, or allocating on the
unmanage heap.
Thanks for the responce.
> The word "fix" is somewhat confusing here. If you really only need to have
> the byte array available for the lifetime of the appDomain, you can just add
[quoted text clipped - 16 lines]
> >
> > Thanks in advance for your thoughts on the matter.
With all due respect, not wanting to use the fixed statement is a very,
very poor reason to keep something pinned in memory like this.
Using an unmanaged buffer is only going to help if you are not going to
access the memory outside of an unsafe context. In that case, you would
have to marshal the memory block back to managed code (and then back to
unmanaged when you are done making changes to it, as well as more than
likely protect access with a lock, if concurrency is a concern).
Why do you not want to use the fixed statement?

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Oops, sorry for the confusion....
> I am using the array in an unsafe context. (via pointers.)
[quoted text clipped - 31 lines]
>> >
>> > Thanks in advance for your thoughts on the matter.
TheMadHatter - 03 Jan 2008 20:34 GMT
Reasoning: (for better or worst)
The byte array is used throughout the life time of the program,
and would have to be fixed -least- every 20ms for processing.
The Idea is that the array would be up and out of the way from
the garbage collector, because there realy isnt a point in including
it in the gc process.
I know the fixed statement doesnt incurr much at all for pinnning,
atleast until the garbage collection cycle is triggered when the
object is pinned.
> With all due respect, not wanting to use the fixed statement is a very,
> very poor reason to keep something pinned in memory like this.
[quoted text clipped - 42 lines]
> >> >
> >> > Thanks in advance for your thoughts on the matter.
Nicholas Paldino [.NET/C# MVP] - 03 Jan 2008 20:43 GMT
This is the kind of situation where you really have to test it out both
ways in order to see what the performance impact is (because that is the
issue here, right?). Because we don't know anything about the allocation
patterns of your app, it's impossible to tell how often a GC would occur,
and how repeated fixed statements would be impacted versus pinning the array
once.
It's something you are going to have to measure, and compare for
yourself.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Reasoning: (for better or worst)
> The byte array is used throughout the life time of the program,
[quoted text clipped - 60 lines]
>> >> >
>> >> > Thanks in advance for your thoughts on the matter.
TheMadHatter - 03 Jan 2008 21:04 GMT
Thanks for your thoughts on the matter.
> This is the kind of situation where you really have to test it out both
> ways in order to see what the performance impact is (because that is the
[quoted text clipped - 70 lines]
> >> >> >
> >> >> > Thanks in advance for your thoughts on the matter.