Booklore – Fix Out of Memory / Java heap Errors

I am a huge fan of Booklore, but my digital book hoarding is really catching up to me. For small libraries I think most people will not have any problems with the out of the box settings — but if you digitally clingy and have things like the Springer collection of books (8,000+) and then a decent amount of books from all the book bundles from Humble Bundle you might soon run into problems

Booklore has had issue 1341 opened since last month and you can find many posts / bug reports prior to this one documenting the same “out of heap space” errors with Java when using Booklore. This heap space is a constant issue with Java Applications. I both understand why it exists and also sometimes lament that it exists. I would not take it away, but dealing with these heap issues and Java are mildly annoying in this modern age.

I run Booklore as a docker image, and the fix is actually really simple.

In your composer file what you want to do is add a environmental variable that specifies a larger initial heap size. I have about 15k documents in Booklore and went with 2GB, but if you have the extra RAM then you can move higher. The environmental variable you want to add to the booklore service is:

- _JAVA_OPTIONS="-Xms2G"

That should look something like this in your docker-compose.yml file:

One snag I ran into is the “G” in the setting needs to be capitol even if your used to specifying a lower case “g” for gigabyte. Same goes if you want to try and use “M” for megabytes, has to be upper case or you will get an error when the JVM launches in the container.

Leave a comment