|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2020-11-20 15:05 UTC] cmb@php.net
-Summary: zlib.inflate filter buffers entire read until file
closed
+Summary: filter buffers entire read until file closed
-Status: Open
+Status: Verified
-Package: Zlib related
+Package: Filter related
[2020-11-20 15:05 UTC] cmb@php.net
[2020-11-21 22:19 UTC] adamjseitz at gmail dot com
[2020-11-21 23:04 UTC] adamjseitz at gmail dot com
[2020-12-23 12:44 UTC] cmb@php.net
-Assigned To:
+Assigned To: cmb
[2020-12-23 12:55 UTC] cmb@php.net
-Status: Verified
+Status: Closed
[2020-12-23 12:55 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 15:00:01 2025 UTC |
Description: ------------ "zlib.inflate" filters appear to buffer all previously-read data, as exhibited by the attached code, until the file is closed. It is unclear from my testing if the data being kept in memory is the original or inflated copy. Test script: --------------- <?php // Generate "data.gz" file with: // dd if=/dev/urandom of=data count=$((8*1024*1024)) iflag=count_bytes; gzip data function PrintMem($message) { echo $message, ": ", (memory_get_usage() / 1024 / 1024) . " MB\n"; } $fp = fopen("data.gz", 'rb'); $filter = stream_filter_append($fp, "zlib.inflate", STREAM_FILTER_READ, array( 'window' => 31 )); PrintMem("before read"); stream_get_contents($fp); PrintMem("after read"); stream_filter_remove($filter); fclose($fp); PrintMem("after close"); ?> Expected result: ---------------- I expect that very little memory is used. It should be possible to read smaller blocks at a time from a very large gzipped files without buffering the entire content of what has been read so far, but that does not seem to be the case. Actual result: -------------- OUTPUT from the above script: before read: 0.44554138183594 MB after read: 8.4377517700195 MB after close: 0.37459564208984 MB