Memory usage in ZK

asked 2012-09-21 07:14:57 +0800

Marky gravatar image Marky flag of Spain
284 7

Hi forum!!

I have been some years working with ZK software, and I try to document this problem searching an answer, but it was unsuccessful.
The main problem is the memory usage when I’m working with the application with a listbox (huge). I have a lot of records to draw into listbox, but always that I do some action in my application the memory usage increases (paging, open in windows and then closing them, etc).

I have tried different options to configure the listbox, even create my own paging to control how many rows are created, but there aren’t any way to solve it, all is useless.
I have used the MAT to try look the problem, and I could see that the problem is the created objects (listcells, listitems, etc). Is that true? After read a lot of it in this forum I note that this is a usual problem into the ZK community and will be good to solve it as soon as possible. Its possible that I’m doing some wrong, then I put a example to see it.
ZK version: 6.0
Tomcat: v.7

This is my listbox (Javaclass):

public class ListBoxMemory extends SelectorComposer<Component> {

	private static final long serialVersionUID = 1L;
	public void init(@ContextParam(ContextType.VIEW) Component view){
		Selectors.wireComponents(view, this, false);
		Selectors.wireEventListeners(view, this);
		Selectors.wireVariables(view, this, null);
	//The binding list
	private List<MemoryBean> BeanList = new ArrayList<MemoryBean>();
	private MemoryBean bean;
	public void Start(){
		//We create the list of bean
	private void createList(){
		for(int i = 0; i < 1000; i++){
			bean = new MemoryBean();

	public List<?> getBeans() {
		return BeanList;

Zul page:

<window title="LBMemory" border="normal" onCreate="@command('Start')"
 apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('org.sts.Pruebas.PruebasMemoria.ListBoxMemory')" height="100%">
	<listbox id="Listbox" mold="paging" pagingPosition="bottom" span="true"  autopaging="true" width="100%" height="100%"  sizedByContent="true" vflex="true" model="@load(vm.beans)" >
		<template name="model" var="item">
				<listitem value="@load(item)"  >
					<listcell label="@load(item.field1)" ></listcell>
					<listcell label="@load(item.field2)" ></listcell>
					<listcell label="@load(item.field3)" ></listcell>
					<listcell label="@load(item.field4)" ></listcell>
					<listcell label="@load(item.field5)" ></listcell>
					<listcell label="@load(item.field6)" ></listcell>
					<listcell label="@load(item.field7)" ></listcell>
					<listcell label="@load(item.field8)" ></listcell>
					<listcell label="@load(item.field9)" ></listcell>
					<listcell label="@load(item.field10)" ></listcell>
					<listcell label="@load(item.field11)" ></listcell>
					<listcell label="@load(item.field12)" ></listcell>
					<listcell label="@load(item.field13)" ></listcell>
					<listcell label="@load(item.field14)" ></listcell>
					<listcell label="@load(item.field15)" ></listcell>
					<listcell label="@load(item.field16)" ></listcell>
					<listcell label="@load(item.field17)" ></listcell>
					<listcell label="@load(item.field18)" ></listcell>
					<listcell label="@load(item.field19)" ></listcell>
					<listcell label="@load(item.field20)" ></listcell>
					<listcell label="@load(item.field21)" ></listcell>
					<listcell label="@load(item.field22)" ></listcell>
					<listcell label="@load(item.field23)" ></listcell>
					<listcell label="@load(item.field24)" ></listcell>
					<listcell label="@load(item.field25)" ></listcell>
					<listcell label="@load(item.field26)" ></listcell>
					<listcell label="@load(item.field27)" ></listcell>
					<listcell label="@load(item.field28)" ></listcell>

The bean:

public class MemoryBean {
	private String Field1 = "";
	private String Field2 = "";
	private String Field3 = "";
	private String Field4 = "";
	private String Field5 = "";
	private String Field6 = "";
	private String Field7 = "";
	private String Field8 = "";
	private String Field9 = "";
	private String Field10 = "";
	private String Field11 = "";
	private String Field12 = "";
	private String Field13 = "";
	private String Field14 = "";
	private String Field15 = "";
	private String Field16 = "";
	private String Field17 = "";
	private String Field18 = "";
	private String Field19 = "";
	private String Field20 = "";
	private String Field21 = "";
	private String Field22 = "";
	private String Field23 = "";
	private String Field24 = "";
	private String Field25 = "";
	private String Field26 = "";
	private String Field27 = "";
	private String Field28 = "";
	public MemoryBean(){
	public String getField1() {
		return Field1;
	public String getField2() {
		return Field2;
	public String getField3() {
		return Field3;
	public String getField4() {
		return Field4;
	public String getField5() {
		return Field5;
	public String getField6() {
		return Field6;
	public String getField7() {
		return Field7;
	public String getField8() {
		return Field8;
	public String getField9() {
		return Field9;
	public String getField10() {
		return Field10;
	public String getField11() {
		return Field11;
	public String getField12() {
		return Field12;
	public String getField13() {
		return Field13;
	public String getField14() {
		return Field14;
	public String getField15() {
		return Field15;
	public String getField16() {
		return Field16;
	public String getField17() {
		return Field17;
	public String getField18() {
		return Field18;
	public String getField19() {
		return Field19;
	public String getField20() {
		return Field20;
	public String getField21() {
		return Field21;
	public String getField22() {
		return Field22;
	public String getField23() {
		return Field23;
	public String getField24() {
		return Field24;
	public String getField25() {
		return Field25;
	public String getField26() {
		return Field26;
	public String getField27() {
		return Field27;
	public String getField28() {
		return Field28;

	public void setField1(String field1) {
		Field1 = field1;
	public void setField2(String field2) {
		Field2 = field2;
	public void setField3(String field3) {
		Field3 = field3;
	public void setField4(String field4) {
		Field4 = field4;
	public void setField5(String field5) {
		Field5 = field5;
	public void setField6(String field6) {
		Field6 = field6;
	public void setField7(String field7) {
		Field7 = field7;
	public void setField8(String field8) {
		Field8 = field8;
	public void setField9(String field9) {
		Field9 = field9;
	public void setField10(String field10) {
		Field10 = field10;
	public void setField11(String field11) {
		Field11 = field11;
	public void setField12(String field12) {
		Field12 = field12;
	public void setField13(String field13) {
		Field13 = field13;
	public void setField14(String field14) {
		Field14 = field14;
	public void setField15(String field15) {
		Field15 = field15;
	public void setField16(String field16) {
		Field16 = field16;
	public void setField17(String field17) {
		Field17 = field17;
	public void setField18(String field18) {
		Field18 = field18;
	public void setField19(String field19) {
		Field19 = field19;
	public void setField20(String field20) {
		Field20 = field20;
	public void setField21(String field21) {
		Field21 = field21;
	public void setField22(String field22) {
		Field22 = field22;
	public void setField23(String field23) {
		Field23 = field23;
	public void setField24(String field24) {
		Field24 = field24;
	public void setField25(String field25) {
		Field25 = field25;
	public void setField26(String field26) {
		Field26 = field26;
	public void setField27(String field27) {
		Field27 = field27;
	public void setField28(String field28) {
		Field28 = field28;


Action - Memory(KB)

Start - 48.748
2nd page - 51.992
14th page - 70.584
Return to 2nd page - 74.232
22nd page - 80.100
10 minutes past -80.172

The memory usage by java process always rises when I paging and never decrease. Increase the server’s memory is the only way to solve it?

Please, I will be very grateful if we could solve this problem.
Thanks for all,

delete flag offensive retag edit

24 Replies

Sort by » oldest newest

answered 2012-10-30 02:10:00 +0800

RichardL gravatar image RichardL
768 4

Thanks, Dennis. I'm interested in this, too. It would be great if you could go through it in more detail in a SmallTalk.

link publish delete flag offensive edit

answered 2012-10-30 08:10:40 +0800

Marky gravatar image Marky flag of Spain
284 7

Lot of thanks Dennis, I will prepare an exemple with Listmodel.
I see the memory leaks with Memory Analizar and I can see that the bulk of instances correspond to ListCells.

I think that its a great idea start a small talk about this, probably some users there are very interested.


link publish delete flag offensive edit

answered 2012-10-30 09:16:28 +0800

dennis gravatar image dennis
3669 1 6

Maybe this old document help, http://books.zkoss.org/wiki/Small_Talks/2009/July/Handling_huge_data_using_ZK
regarding to MVVM with huge data, I will arrange time do write a smalltalk, please be patient.

link publish delete flag offensive edit

answered 2012-10-30 11:47:33 +0800

Marky gravatar image Marky flag of Spain
284 7

I have read this page this morning and I tryed to download the code, but i think that the downloaded code is wrong (or I done something wrong).

But its very interesting, lot of thanks Dennis! I wait your smalltalk expectant :D


link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2012-09-21 07:14:57 +0800

Seen: 692 times

Last updated: Oct 30 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More