Bug 29632 - Rendered reads fonts from disk everytime it renders PDF.
Summary: Rendered reads fonts from disk everytime it renders PDF.
Status: NEW
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: pdf (show other bugs)
Version: 0.20.4
Hardware: HP HP-UX
: P3 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-17 08:05 UTC by Tomas Kyjak
Modified: 2012-04-07 01:37 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Kyjak 2004-06-17 08:05:28 UTC
Even if you reuse an instance of a Driver object, renderer reads all font 
definitions (.xml) from disk everytime it processes a document. Font instances 
are not reused, a lot of memory is allocated and freed immediately, IO 
operations are huge.
You can try the following code to see how it behaves.


import org.apache.fop.configuration.ConfigurationReader;
import org.apache.fop.apps.InputHandler;
import org.apache.fop.apps.Driver;
import org.xml.sax.InputSource;

import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.*;
import java.io.*;
import java.util.Date;

public class FOP {

	public static void main(String[] args) {
		try {
			StreamSource ss = new StreamSource(new StringReader("<< 
Put XML here >>"));
      StreamSource ss2 = new StreamSource(new StringReader("<< Put XSL here 
>>"));

			TransformerFactory tf = TransformerFactory.newInstance
();
			Templates ts = tf.newTemplates(ss2);
			Transformer t = ts.newTransformer();

			ByteArrayOutputStream resultstream = new 
ByteArrayOutputStream();

			Result res = new StreamResult(resultstream);
			t.transform(ss, res);

			ConfigurationReader reader = new ConfigurationReader
(InputHandler.fileInputSource(new File("/xslconfig/conf/userconfig.xml")));

			reader.start();

			ByteArrayOutputStream fos = new ByteArrayOutputStream();
			ByteArrayInputStream fis = new ByteArrayInputStream
(resultstream.toByteArray());
			ByteArrayInputStream fis2 = new ByteArrayInputStream
(resultstream.toByteArray());
			InputSource is = new InputSource(fis);
			InputSource is2 = new InputSource(fis2);

			System.out.println(new Date() + "Sleeping for 20 
seconds before first rendering, check IO read bytes now...");
			Thread.sleep(20000);

			Driver driver = new Driver(is, fos);
			driver.run();

			System.out.println(new Date() + "Sleeping for 20 
seconds after first rendering, check IO read bytes now...");
			Thread.sleep(20000);

			driver.setInputSource(is2);
			driver.setOutputStream(fos);
			driver.run();

			System.out.println(new Date() + "Sleeping for 20 
seconds after seconds rendering, check IO read bytes now...");
			Thread.sleep(20000);


		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
Comment 1 Glenn Adams 2012-04-07 01:37:09 UTC
resetting severity from major to normal pending further review