gcross: > Thanks, Don. What made me think that this might be possible was the > existence of Foreign.StablePtr, since that seems to take a Haskell > expression and pin it down. Could this mechanism be harness to pin down > arrays, or am I misunderstanding how it works? (Is StablePtr really just > making a copy of the expression behind the scenes?)
That doesn't make the memory actually stable, it just keeps a dynamic association between a stable pointer and the actual memory address, so you can look up where a block of memory has moved to, keying only with a pointer-sized value. > My motivation for this is that I will be sweeping back and forth along a > data structure that is chain of memory blocks (essentially a pointed > list), with ~ 10 to 1000 beads. At any given time I am only working > with and updating one bead on the chain, so I am wondering if trying to > use unpinned memory for the beads not in use would help by speeding up > allocations and allowing the g.c. to rearrange their layout in memory. > Each bead has a few memory chunks ranging from ~ 100 bytes to possibly up > to tens of kilobytes, depending on a scaling parameter on my algorithm. If there are many small chunks, unpinned memory is better. Might be ok to copy into pinned memory for the foreign call. -- Don _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe