The current implementation of readBlock allocates a new memory buffer every time a new block of 2880 bytes is to be read (see here). This generates additional unnecessary work to the garbage collector when decoding thousands of files in a single execution of a program using astrogo/fitsio.
This situation could be improved by associating a buffer of the appropriate size to a streamDecoder and reuse that buffer for reading each block of the same FITS file.
Alternatively, a single buffer could be allocated by the DecodeHDU() method and that buffer could be reused to perform all the necessary read operations while decoding the entire HDU.
The current implementation of
readBlock
allocates a new memory buffer every time a new block of 2880 bytes is to be read (see here). This generates additional unnecessary work to the garbage collector when decoding thousands of files in a single execution of a program usingastrogo/fitsio
.This situation could be improved by associating a buffer of the appropriate size to a
streamDecoder
and reuse that buffer for reading each block of the same FITS file.Alternatively, a single buffer could be allocated by the
DecodeHDU()
method and that buffer could be reused to perform all the necessary read operations while decoding the entire HDU.