<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Crash when trying to copy image"
   href="https://bugs.webkit.org/show_bug.cgi?id=125868#c5">Comment # 5</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Crash when trying to copy image"
   href="https://bugs.webkit.org/show_bug.cgi?id=125868">bug 125868</a>
              from <span class="vcard"><a class="email" href="mailto:WebKit&#64;JeremyZerfas.com" title="Jeremy Zerfas &lt;WebKit&#64;JeremyZerfas.com&gt;"> <span class="fn">Jeremy Zerfas</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=125868#c4">comment #4</a>)

<span class="quote">&gt; &gt; Source/WebCore/ChangeLog:12
&gt; &gt; +        No new tests needed.
&gt; 
&gt; Why are not no new tests needed for this change?</span >

I didn't think it was possible to get the memory statistics needed for testing but after doing a more thorough search I found the mallocStatistics() function which will be sufficient. I've created a new patch that now includes a test for this.

<span class="quote">&gt; &gt; Source/WebCore/platform/mac/PasteboardMac.mm:258
&gt; &gt; +    NSData *imageData = (NSData*)(pasteboardImage.image-&gt;getTIFFRepresentation());
&gt; 
&gt; I think this is wrong. The clipboard has to manage deallocating its own
&gt; data. The original data can be freed or even the whole application gets shut
&gt; down but the clipboard should keep its data. In other words, I think a new
&gt; memory buffer has to be allocated every time we want to write to the
&gt; clipboard.</span >

I'm pretty sure that assessment is wrong but I might have misled you because I was mistaken about the NSImage allocation causing much of the extra memory use. The difference in memory usage is primarily due to using getTIFFRepresentation() to get the TIFF data instead of using getNSImage() to allocate a NSImage (which is just a wrapper around the data returned from getTIFFRepresentation() anyway) and then calling TIFFRepresentation on the NSImage which requires more overhead. The clipboard doesn't need the NSImage, it only needs the TIFF data which is still being allocated. As a bit of a proof of this, pasting the animation from the clipboard into another app still works fine even after quitting the patched browser. Hope that clears things up.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>