H2 database PageStore causing OutOfMemoryError

322 views Asked by At

I'm using H2 as a simple embedded database to store less than 10,000 records but have started encountering an OutOfMemoryError.

Examining the heap dump the org.h2.store.PageStore has a retained size of almost 800mb for what should only be 5 to 10 megabytes worth of data.

What steps can I do to further debug and resolve this problem?

heapdump

1

There are 1 answers

0
James Allman On BEST ANSWER

It turns out I was experiencing a side effect from the change in string representation made in update 7u6.

My development environment is post 7u6 whereas production was running an earlier version and I could not duplicate the issue.

It was not an issue with the PageStore at all except for the huge retained size due to the string references.

TIL Oracle changed the internal String representation in Java 7 Update 6 increasing the running time of the substring method from constant to N