1 Sep 2005 16:36
Profiling and analysing space usage
Alistair Bayley <abayley <at> gmail.com>
2005-09-01 14:36:09 GMT
2005-09-01 14:36:09 GMT
Hello all. Below is a (typically pointless) program, which is a small slice from a larger one I'm profiling. I'm interested in getting the memory usage as small as possible. The loop function (and its analogue in the real program) contributes significantly to the allocation stats. AFAICT, this would be mainly due to a closure built for the if-stmt. The heap profile graph for this program shows an initial peak, and then the graph is flat at 8Mbytes, which I think is the space allocated to the two STArrays (2 arrays, 1 million chars each, 4 bytes per char?). So it looks as though any allocation for the loop function is GC'd very soon after it's allocated. So my questions are: - is my analysis of the space usage correct i.e. allocation in the loop function is very short-lived and nothing to worry about? - is there anything I can do to reduce the memory usage, or is it already minimal, assuming that I'm happy with the size of the STArrays? I realise I could use, say, PackedStrings, but the original program works on lists of (Eq a); I've just chosen Chars for this example so as to eliminate polymorphism from the profiling. Notes: - exporting only main makes a *big* difference to both space and time usage, as does adding type signatures, to eliminate polymophism. This is the only retainer set shown on the profiling graph:(Continue reading)
RSS Feed