converting 360 pages' pdf file take too much memory

王可 <[email protected]> Fri, 10 Mar 2017 10:36:49 +0800
Newsgroups gmane.comp.video.graphicsmagick.apis
Message-ID <CAPE5Tz-wpb6+zDSZeWHDxnpSX7DAZNCgvSVC4ZOK2yYsSzL8tA@mail.gmail.com>
--===============4057642736215264128==
Content-Type: multipart/alternative; boundary=001a1143a44a38c2f9054a573e4c

--001a1143a44a38c2f9054a573e4c
Content-Type: text/plain; charset=UTF-8

Hi,

I used *readImages* to read pdf file and put all image blobs into a single
pack file in my project.
When I test my program with a pdf file which is 7 MB, 360 pages, I found
the max memory usage is 1.5G.
with following code that just output each page into a image, the memory
usage is also high.

InitializeMagick(*argv);
> std::list<Image> images;
> readImages(&images, "/test/linuxfun.pdf");
> size_t i;
> std::list<Image>::iterator image;
> for (image = images.begin(), i = 0; image != images.end(); image++, i++)
> image->write("/test/output/test." + std::to_string(i) + ".jpg");


If I increase image density with overwrited readImages, the memory usage is
higher.
Since api read and output each page one by one, why it take so much memory
and is there any solution for it?

Another question is, When I run the program, A progress "gs"  runs in
background and exits after a while, then I can see process of my program in
process list.
I do not understand what 'gs' process is and how it running.

-- 
Thanks,

--001a1143a44a38c2f9054a573e4c
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div><div>Hi, <br><br></div>I used <b>readImages</b> =
to read pdf file and put all image blobs into a single pack file in my proj=
ect.<br></div>When I test my program with a pdf file which is 7 MB, 360 pag=
es, I found the max memory usage is 1.5G. =C2=A0 <br></div>with following c=
ode that just output each page into a image, the memory usage is also high.=
 <br><div><div><div><div><div><div><div><div><div><div><div><div><br><block=
quote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1=
px solid rgb(204,204,204);padding-left:1ex"><span style=3D"background-color=
:rgb(255,255,255)"><span style=3D"color:rgb(0,0,0)">InitializeMagick(*argv)=
;</span></span><br><span style=3D"background-color:rgb(255,255,255)"><span =
style=3D"color:rgb(0,0,0)">std::list&lt;Image&gt; images;</span></span><br>=
<span style=3D"background-color:rgb(255,255,255)"><span style=3D"color:rgb(=
0,0,0)">readImages(&amp;images, &quot;/test/linuxfun.pdf&quot;);</span></sp=
an><br><span style=3D"background-color:rgb(255,255,255)"><span style=3D"col=
or:rgb(0,0,0)">size_t i;</span></span><br><span style=3D"background-color:r=
gb(255,255,255)"><span style=3D"color:rgb(0,0,0)">std::list&lt;Image&gt;::i=
terator image;</span></span><br><span style=3D"background-color:rgb(255,255=
,255)"><span style=3D"color:rgb(0,0,0)"><span style=3D"font-weight:bold">fo=
r </span>(image =3D images.begin(), i =3D 0; image !=3D images.end(); image=
++, i++)</span></span><br><span style=3D"background-color:rgb(255,255,255)"=
><span style=3D"color:rgb(0,0,0)">    image-&gt;write(&quot;/test/output/te=
st.&quot; + std::to_string(i) + &quot;.jpg&quot;)</span><span style=3D"colo=
r:rgb(204,120,50)"><span style=3D"color:rgb(0,0,0)">;</span></span></span><=
/blockquote><div><br></div><div>If I increase image density with overwrited=
 <span style=3D"background-color:rgb(255,255,255)"><span style=3D"color:rgb=
(0,0,0)">readImages, the memory usage is higher. <br></span></span></div><d=
iv><span style=3D"background-color:rgb(255,255,255)"><span style=3D"color:r=
gb(0,0,0)">Since api read and output each page one by one, why it take so m=
uch memory and is there any solution for it?=C2=A0 <br><br></span></span></=
div><div><span style=3D"background-color:rgb(255,255,255)"><span style=3D"c=
olor:rgb(0,0,0)">Another question is, When I run the program, A progress &q=
uot;gs&quot;=C2=A0 runs in background and exits after a while, then I can s=
ee process of my program in process list.<br></span></span></div><div><span=
 style=3D"background-color:rgb(255,255,255)"><span style=3D"color:rgb(0,0,0=
)">I do not understand what &#39;gs&#39; process is and how it running. <br=
></span></span></div><div><span style=3D"background-color:rgb(255,255,255)"=
><span style=3D"color:rgb(0,0,0)"><br></span></span> </div>-- <br><div clas=
s=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir=
=3D"ltr">Thanks,</div><div dir=3D"ltr"><br><table style=3D"color:rgb(0,0,0)=
;font-size:12px;font-family:arial;line-height:17px" cellspacing=3D"0" cellp=
adding=3D"0" width=3D"480" border=3D"0"><tbody><tr><td style=3D"text-align:=
center;padding:15px 0px 15px 15px" width=3D"120"><br></td><td style=3D"padd=
ing:15px 0px 15px 15px" valign=3D"top"></td></tr></tbody></table></div></di=
v></div></div></div></div>
</div></div></div></div></div></div></div></div></div></div></div></div></d=
iv>

--001a1143a44a38c2f9054a573e4c--


--===============4057642736215264128==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
--===============4057642736215264128==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Graphicsmagick-apis mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-apis

--===============4057642736215264128==--