pointers - Prevent object from being moved by garbage collector in F# -
in c# es easy pin object place stored using keyword "fixed". here example msdn:
unsafe static void testmethod() { // assume class point { public int x, y; } // pt managed variable, subject garbage collection. point pt = new point(); // using fixed allows address of pt members // taken, , "pins" pt isn't relocated. fixed (int* p = &pt.x) { *p = 1; } }
how can done in f#?
you can use gchandle type pinned
Comments
Post a Comment