fixed

  • Blocks of managed memory allocated on the managed heap might get relocated due to garbage collection.
  • To avoid this blocks of memory are locked using the fixed statement
  • The fixed statement is made up of two parts:
    • An expression that can be converted to an unmanaged type, and
    • The declaration of an unmanaged type variable that's assigned the value of the expression.
  • The address is locked until the statement or statement block that follows the fixed statement has finished executing.
  • The fixed statement can target any managed memory block, including instance or static class fields, but the variable that's the target of the fixed statement must be a value type, an array, or a string. It can also lock multiple memory blocks, if they are of the same type
  • Locking the memory degrades the performance. So care must be taken lock it for a short duration

0 comments :

Post a Comment

> Related Posts with Thumbnails
 

Copyright © 2012. GS dot net - All Rights Reserved - Design by BTDesigner - Proudly powered by Blogger