Skip Menu |

This queue is for tickets about the File-Scan-ClamAV CPAN distribution.

Report information
The Basics
Id: 78769
Status: resolved
Priority: 0/
Queue: File-Scan-ClamAV

People
Owner: ESAYM [...] cpan.org
Requestors: jschroeder [...] multiad.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.91
Fixed in: (no value)



Subject: Memory leak in streamscan()
There seems to be a nasty memory leak in streamscan(). The regular scan() from a file seems OK. To repeat: Read in a file, pass the contents to streamscan(). Observe that a ton of memory is used and never reclaimed. I had a 150mb zip eat up over 1GB(!). SunOS 5.10 ClamAV 0.97.2
For the most part this is working as intended. Let me explain: To use streamscan, you clearly have to already have the data in ram. A file read in by perl typically uses 50% more data in memory than disk size. So a 150MB file will take >200MB if read into a perl variable. Then you pass that data into streamscan, that creates yet another copy of the data in the screamscan function, now we are at >400MB. streamscan than passes the data to _send(), when creates another copy. So this puts mem usage above 600MB. In perl 5.20+, the new copy on write feature (COW), should help here since the data of this file is not being modified, just being passed through functions. However, the call to join() on the data variable in streamscan was preventing this so I removed that. That cut the mem usage in half for perls 5.20+. However older perls had no effect. I therefore changed the way arguments were handled in _send(), just use the aliases/references in the function instead of copying the data into another variable. The outcome in perl 5.20+ is mem usage does not grow beyond the initial size when the file was read into mem. However on perls < 5.20, the mem usage still doubles (but before it would triple so there is still some benefit here) Committed to 1.93.