Bug 102481 - PDF creation memory usage
Summary: PDF creation memory usage
Status: RESOLVED NOTABUG
Alias: None
Product: cairo
Classification: Unclassified
Component: pdf backend (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Adrian Johnson
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-30 14:43 UTC by Tony Teveris
Modified: 2017-09-14 12:13 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
partical code c++ (4.83 KB, text/plain)
2017-08-30 14:43 UTC, Tony Teveris
Details
Low res image of marker (86.41 KB, image/jpeg)
2017-08-30 18:39 UTC, Tony Teveris
Details

Description Tony Teveris 2017-08-30 14:43:45 UTC
Created attachment 133883 [details]
partical code c++

Windows 8.1 32 bit application, Cairo 1.15.2 - I'm trying to create a PDF with a a large number of big images. The overall PDF size in inches is 150" x 60" and I have PNG images that are 4k x 6k x 32 bit. The images are from from files as you can see in the attached code I build a surface with the image and add it to the context.

For each image I can see the memory usage going up until I hit 1gb and then things start to fail (out of memory). I using the following to check usage:

    PROCESS_MEMORY_COUNTERS_EX pmc;
    pmc.cb = sizeof(PROCESS_MEMORY_COUNTERS_EX);
    GetProcessMemoryInfo(GetCurrentProcess(), (PROCESS_MEMORY_COUNTERS *)&pmc, sizeof(pmc));

pmc.WorkingSetSize

The attached code is c# but I have a wrapper to the c++ library.

So my question is does cairo hold on to each surface even though I destroyed it when I'm done? Or does cairo hold the info until the end of the process when the PDF is actually written to disk?

Just trying to figure out how to move forward on this memory issue.

Thanks
Comment 1 Tony Teveris 2017-08-30 18:39:23 UTC
Created attachment 133891 [details]
Low res image of marker

This is a low res image of what I'm trying to export as PDF.

The PDF will NOT contain the text you see on each piece you see in the image.
Comment 2 Tony Teveris 2017-08-30 18:46:37 UTC
I have a PDF just before the "no memory" error, basically forcing completion via debug but it's 141mb and can not be attached
Comment 3 Adrian Johnson 2017-08-30 22:18:00 UTC
The images for each page are held until cairo_show_page is called. Then they a freed after the page is written to disk.
Comment 4 Adrian Johnson 2017-08-30 22:26:14 UTC
Also, if you are creating huge PDFs you are really better off using a 64-bit version.
Comment 5 Tony Teveris 2017-08-31 13:35:34 UTC
Ok, I here you on the 64 bit solution. For now what I did was create a multi page PDF with each "piece" on a page in the proper location.

Do you know of any way to "flatten" all pages of a PDF into one page?

Thanks
T
Comment 6 Adrian Johnson 2017-09-14 12:13:56 UTC
Problem is due to the memory constraints of using a 32-bit build.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.