Tk Library Source Code

View Ticket
Login
Ticket UUID: 579026
Title: crc32 consumes lots of memory
Type: Bug Version: None
Submitter: arjenmarkus Created on: 2002-07-09 08:11:30
Subsystem: crc Assigned To: patthoyts
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2002-09-27 06:19:33
Resolution: Fixed Closed By: patthoyts
    Closed on: 2002-09-26 23:19:33
Description:
crc32 consumes a large amount of memory if it has to
determine the checksum for a large file (a file of10 MB
causes the process to consume 200 MB of memory). This
is probably due to the use of a list containing
elements of 1 character (each list element has an
overhead of 12 bytes).

Alternative implementation:

   for { set i 0 } { $i < $length } { incr i } { 
      scan [string range $str $i $i] c n
      ...
   }
User Comments: patthoyts added on 2002-09-27 06:19:33:
Logged In: YES 
user_id=202636

This is mostly a problem in that we are sucking in the
entire file in one go and then processing it. I have
implemented a more moderate buffering read which will reduce
the memory requirement, Doesn't work for Trf based crc32 though.

arjenmarkus added on 2002-07-09 16:28:50:
Logged In: YES 
user_id=400048

Follow-up: with Tcl 8.4 this will not be a problem as the
list elements will be cached, amounting to 256 distinct
Tcl_Objs only (Donal Fellows checked this).