Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

enter image description here

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.

like image 583
Lubomír Sedlář Avatar asked Dec 09 '13 19:12

Lubomír Sedlář


1 Answers

"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).

like image 122
Tom Ellis Avatar answered Oct 21 '22 21:10

Tom Ellis