What does PINNED mean in -hc profile of Haskell program?

时光怂恿深爱的人放手 提交于 2019-12-22 01:24:44

问题


I am trying to profile my application. When analyzing memory usage with -hc RTS option, I noticed lots of memory marked as PINNED. When running with -hy the memory is marked as ARR_WORDS.

The program creates a 2400×2400 matrix of doubles using Data.Packed.Matrix module from hmatrix package, and since the elements in it should be stored in continuous memory, I don't see a way for the matrix to take up so much space.

My question is: what does the PINNED word actually mean? Also is there a way to get further information on why and where the memory is used?

The whole source code in question is on GitHub, should anyone be interested in it. However, it is very far from minimal example.


回答1:


"Pinned" data means that the garbage collector is not allowed to move it. This helps, for example, when passing data to C functions via the FFI. You wouldn't want the GC to move the data whilst the C call is executing.

Soylet Green gave the relevant link above (https://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/GC/Pinned).



来源:https://stackoverflow.com/questions/20478805/what-does-pinned-mean-in-hc-profile-of-haskell-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!