Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4786

memory leak with MVVM data binding

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 9.5.1
    • 9.1.0, 8.5.1.3, 9.5.0.2
    • Databind 2
    • Security Level: Jimmy

      Steps to Reproduce

      ViewModel

      public class MemLeakVM {
      	private int idx = 0;
      	private Bean bean = new Bean(idx++);
      	@Command
      	public void refresh() {
      		bean = new Bean(idx++);
      		BindUtils.postNotifyChange(null, null, this, "bean");
      	}
      	public Bean getBean() { return bean; }
      	public class Bean {
      		private final int idx;
      		public Bean(int idx) {  this.idx = idx; }
      		public int getIdx() { return idx; }
      	}
      }
      

      zul

      <zk>
      	<div viewModel="@id('vm') @init('MemLeakVM')">
      		<apply obj="@load(vm.bean)">
      			<label value="${obj.idx}"/>
      		</apply>
      		<button onClick="@command('refresh')" label="Refesh"/>
      	</div>	
      </zk>
      

      1) load the page
      2) take a heap dump
      3) click the Refresh button
      4) take a heap dump
      ... repeat 3,4,3,4

      Current Result

      then number of MemLeakVM$Bean instances increases in memory (old objects are not GCed)

      Expected Result

      only a single instance of MemLeakVM$Bean in memory

      Debug Information

      Workaround

            DevChu DevChu
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: