<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>203991</bug_id>
          
          <creation_ts>2019-11-07 22:43:49 -0800</creation_ts>
          <short_desc>Safari leaks memory of Cache/Response objects of CacheStorage API</short_desc>
          <delta_ts>2020-03-24 02:07:52 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>Safari Technology Preview</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Konstantin Kaefer">mail</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>cdumez</cc>
    
    <cc>ddkilzer</cc>
    
    <cc>joepeck</cc>
    
    <cc>koivisto</cc>
    
    <cc>rniwa</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1588579</commentid>
    <comment_count>0</comment_count>
      <attachid>383113</attachid>
    <who name="Konstantin Kaefer">mail</who>
    <bug_when>2019-11-07 22:43:49 -0800</bug_when>
    <thetext>Created attachment 383113
Memory leak with CacheStorage/Cache/Response

When using the CacheStorage API and calling `cache.keys()` to retrieve all items stored in a cache, Safari won&apos;t free the memory of those objects.

The attached sample page opens the Cache repeatedly, and requests keys. Memory grows to several gigabytes in the span of a few seconds.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1604229</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-01-08 12:16:38 -0800</bug_when>
    <thetext>&lt;rdar://problem/58417259&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1604592</commentid>
    <comment_count>2</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2020-01-09 06:46:44 -0800</bug_when>
    <thetext>Doing a quick test, the script creates lots of objects that at some point gets collected.
I do not see a leak per se although we should probably try to improve memory management, in particular not send response body until actually requested by the page.

Konstantin, can you validate that memory consumption does not increase forever on your setup as well?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1604594</commentid>
    <comment_count>3</comment_count>
    <who name="Konstantin Kaefer">mail</who>
    <bug_when>2020-01-09 06:51:41 -0800</bug_when>
    <thetext>Thanks for looking into this issue. It looks like it&apos;s growing linearly until ~3GB on my machine, then some objects are garbage collected. It seems like the garbage collector isn&apos;t aware of the true size of these objects, so it doesn&apos;t collect them even though they take up a lot of memory.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1633255</commentid>
    <comment_count>4</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2020-03-24 02:07:52 -0700</bug_when>
    <thetext>I removed buffering of request/response in https://bugs.webkit.org/show_bug.cgi?id=209425. That should help this.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>383113</attachid>
            <date>2019-11-07 22:43:49 -0800</date>
            <delta_ts>2019-11-07 22:43:49 -0800</delta_ts>
            <desc>Memory leak with CacheStorage/Cache/Response</desc>
            <filename>cache.html</filename>
            <type>text/html</type>
            <size>712</size>
            <attacher name="Konstantin Kaefer">mail</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KICAgIDxtZXRhIGNoYXJzZXQ9J3V0Zi04JyAv
PgogICAgPHRpdGxlPkNhY2hlU3RvcmFnZSBtZW1vcnkgbGVhazwvdGl0bGU+CjwvaGVhZD4KPGJv
ZHk+CjxzY3JpcHQ+CgovLyBJbnNlcnQgYSBmZXcgZWxlbWVudHMgaW50byB0aGUgY2FjaGUsIHRo
ZW4gc3RhcnQgcmVxdWVzdGluZyBpdGVtcy4Kd2luZG93LmNhY2hlcy5vcGVuKCd0ZXN0JykKICAg
IC50aGVuKGNhY2hlID0+IHsKICAgICAgICBQcm9taXNlLmFsbChbLi4uQXJyYXkoMjUpLmtleXMo
KV0ubWFwKG5hbWUgPT4gewogICAgICAgICAgICBjb25zdCBidWZmZXIgPSBuZXcgQXJyYXlCdWZm
ZXIoMTAyNCAqIDEwMjQpOwogICAgICAgICAgICBjYWNoZS5wdXQoYGh0dHA6Ly9leGFtcGxlLmNv
bS8ke25hbWV9YCwgbmV3IHdpbmRvdy5SZXNwb25zZShidWZmZXIpKTsKICAgICAgICB9KSkudGhl
bihyZXF1ZXN0S2V5cyk7CiAgICB9KTsKCmZ1bmN0aW9uIHJlcXVlc3RLZXlzKCkgewogICAgc2V0
SW50ZXJ2YWwoKCkgPT4gewogICAgICAgIHdpbmRvdy5jYWNoZXMub3BlbigndGVzdCcpCiAgICAg
ICAgICAgIC50aGVuKGNhY2hlID0+IHsKICAgICAgICAgICAgICAgIGNhY2hlLmtleXMoKTsKICAg
ICAgICAgICAgICAgIGNhY2hlID0gbnVsbDsKICAgICAgICAgICAgfSk7CiAgICB9LCAxMDApOwp9
Cgo8L3NjcmlwdD4KPC9ib2R5Pgo8L2h0bWw+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>