Your file's size is 50K, but readFile
reads file by 32k chunks. So you have half of the file in memory. Except that, some memory is used for runtime system, gc, intermediate lazy string in print
, etc. So 60K max residency is ok.
You can try with bigger file, e.g. 100M. You'll see that max residency will not grow.
If the default chunk size is not ok for you, then try hGetSome