• Alan Screen's avatar
    [Windows] Release page metafile after printing to GDI API · 711f8a01
    Alan Screen authored
    Printing on Windows involves a two-step process, first converting pages
    to the Windows metafile format (EMF) and then later playing that
    metafile to print to the destination device.
    
    The PrintedPage objects which contain this metafile data are retained
    in the PrintedDocument until the document completes.  This has caused
    the extra metafile representation to stay in memory well after it's
    required lifetime has passed.  For jobs with many pages that include
    full page rasters this triggers a memory spike that subsides only once
    the last page is sent and the document is destroyed.
    
    Avoid such memory spikes by dropping the PrintedPage object from the
    document as soon as the page has been rendered to the destination, so
    that its destructor can run and release the associated |metafile_|
    memory.
    
    Bug: 1031438
    Change-Id: If6ff81f63e11989bc7ef1b341ee37be0cd8d4af7
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1975993Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
    Commit-Queue: Alan Screen <awscreen@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#726671}
    711f8a01
printed_document.cc 9.9 KB