|
-
January 25th, 2008, 03:07 PM
#9
Re: Grr, garbage collector, don't move my arrays!
 Originally Posted by DeepT
Out of curiosity, what kind of C# application needs a block of memory in a fixed location? Even when considering IPC, you share memory blocks via system objects, not actual memory addresses.
A C# application that needs to call a native Windows function. If that function needs a buffer to read from, if you don't pin the memory, the garbage collector might move it and the native function trying to read it will fail.
A fixed statment works but I, personally, prefer not using unsafe code. Using a GCHandle is the managed way of doing it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|