Managing memory usage on pure-in-memory application

39 views
Skip to first unread message

Peter Childs

unread,
Apr 18, 2012, 2:30:33 AM4/18/12
to h2-da...@googlegroups.com
Gday folks.

I have been using H2 in an application where I store packet off the wire in a database with no disk persistence (it is not required)

I have found that I can store about 17million rows (packets) in a table in about say 31gb of RAM without issues, and the stability is great.

I feel that currently I am managing my database size/memory in a 'wrong' way.

I have a monitoring thread that every 5 seconds checks memory usage, and if greater than 93% I delete 1% of the oldest rows in the table.

ie.
  MemoryUsage mu = mbean.getHeapMemoryUsage();
  double pU = (double) mu.getUsed() / (double) mu.getMax() * 100;
  if (pU > 93) {  // do things };

This has been typically successful in stopping the app exploding with a OutOfMemory exception.

Is there a better way of managing this (ie ways to understand how much memory a table is using etc?)

Cheers,
   Peter

Thomas Mueller

unread,
Apr 23, 2012, 1:03:22 PM4/23/12
to h2-da...@googlegroups.com
Hi,

There are other ways, but it's hard to say if they are better or not. If performance is the most important problem, then it sounds like a good solution.

For example, you could use the in-memory file system and a large cache size: jdbc:h2:memFS:test - or you could use the compressing in-memory file system: jdbc:h2:memLZF:test. This will slow down processing, but save memory. But in both cases you may still need to delete data from time to time.

Regards,
Thomas
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/dt7OhI8UFNIJ.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.
Reply all
Reply to author
Forward
0 new messages