samskivert / jmustache

A Java implementation of the Mustache templating language.
Other
841 stars 128 forks source link

Mustache.compiler().compile throws java.lang.OutOfMemoryError while compiling a big file #67

Closed sameerarora closed 9 years ago

sameerarora commented 9 years ago

Reader in=new InputStreamReader(new FileInputStream(new File("/Users/sameerarora/dependencies.txt"))); Mustache.compiler().escapeHTML(true).compile(in);

The above code throws an OutOfMemory error if the file is bigger than a certain size. I tried with a file of size 600 MB. I am using jMustache version 1.9.

samskivert commented 9 years ago

JMustache is not designed for one-pass operation over large files. It parses the entire file into memory and keeps the contents in memory, and generates output from the in-memory parsed representation.

A 600MB file is going to probably double in size because Java converts bytes into 16-bit chars for in-memory representation, so you can probably do what you need if you give Java a big max heap size, but otherwise JMustache is probably not the right tool for this job.