Avoiding out of memory exception while loading items in Table


I have a table which contains 7 columns, out of which 1 column holds a horizontal layout with two buttons in it and all others hold String values.
The number of rows loaded in the table range from 100,000 to 1,000,000. With a allocated heap space of 1 GB, I run into out of memory exception while loading the items in the table. Is there a possible pagination implementation or any other solution that can be done to avoid this exception ?


There is already Paging in the Client, but not in the Server.

You should give your Server more memory.

When you want to have Server-Side Paging you have to build it on your own or use lazy query container addon.


Like they said. If you load everything in memory, everything will be in memory. If want to list that many rows in your UI table, there is probably already something wrong in it from user experience wise. I hope you have some search controls :slight_smile: One option is just to list n first rows from the DB and optionally provided paging controls.

The paging can also be done at “container level”. Although not an official Vaadin ltd solution, I can hightly recommend the LazyQueryContainer suggested by Petrus. That is easy helper to build a container that only loads visible rows into the memory of the server.

Also our default containers like BeanItemContainer uses quite a lot of memory (and CPU). If you swich to use ListContainer class from addon called
, memory reservation might drop into about one tenth.