user1616357
user1616357

Reputation: 11

How to compress memory space of h2 database ( in-memory mode)?

h2 seems to take up too much memory space, How to compress it

Upvotes: 1

Views: 3012

Answers (1)

Thomas Mueller
Thomas Mueller

Reputation: 50147

Do you use the in-memory mode (database URL jdbc:h2:mem:test or similar)? H2 uses a pluggable file system / file system abstraction, and as part of that there is are two in-memory file system implementations, one of them compresses the data. To use it, use one of the following database URLs:

  • jdbc:h2:memFS:test (regular in-memory file system; a bit slower than jdbc:h2:mem:test but uses a bit less memory)
  • jdbc:h2:memLZF:test (compressed in-memory file systems; slower than the above but uses less memory, maybe half or a third)

If you use the persisted mode: H2 uses quite little memory by default for the cache (16 MB), but you can reduce the cache size if needed (see the docs).

Upvotes: 5

Related Questions