Subject: | Using "OO" mode and add method blows up memory |
Date: | Wed, 21 Aug 2013 15:54:17 -0700 |
To: | bug-Digest-CRC [...] rt.cpan.org |
From: | Brian Moran <bmoran [...] onehub.com> |
The 'add' method, as it stands today, seems to take the provided data, and
just append it to a structure which is kept in memory. Only when the
results are asked for does the crc function actually get run, and the data
buffer used. So, if one is attempting to crc a large amount of data (say, a
2GB file), the memory used by the process using the add method grows by at
least 2GB.
It would be better to modify the 'add' method so that it will crc the
buffer that is supplied, then save the partial result. It should not save
any more data than necessary.
The Digest::SHA1 and Digest::MD5 libraries work by computing partial sums
buffer by buffer, and don't exhibit the memory consumption issue.
Until it can be so modified, it would be very helpful to at document this
behavior and warn to use the functional style (e.g. crc32("123456789"))
instead of the OO style.
Thanks,
Brian Moran
--
e: bmoran@onehub.com
p: +1 206 390 4376
Onehub, Inc.
www.onehub.com