New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ビューにバインド後、ObservableArrayにObservableItemの追加と削除を繰り返すとメモリ使用量が増加する #245

Closed
mtakeuchi opened this Issue Sep 19, 2013 · 0 comments

Comments

Projects
None yet
2 participants
@mtakeuchi
Contributor

mtakeuchi commented Sep 19, 2013

IE7,8で発生することを確認。

HTML

<body>
  <div id="result" data-h5-loop-context="data">
    <div data-h5-bind="message"></div>
  </div>
</body>

JavaScript

IE7では以下のコードを実行すると、約40,000kメモリを使用する

var infoItems = h5.core.data.createObservableArray();
h5.core.view.bind('#result', {data:infoItems});

for (var i = 0; i < 1000; i++) {
  var item = h5.core.data.createObservableItem({
    message: {
      type: 'number'
    }
  });
  item.set('message', i);
  infoItems.unshift(item);

  if (infoItems.length > 10) {
    infoItems.pop();
  }
}

なお、DataItemではObservableItemほどメモリを使用しない
IE7では以下のコードを実行すると、約25,000kメモリを使用する

var infoItems = h5.core.data.createObservableArray();
  h5.core.view.bind('#result', {data:infoItems});

var manager = h5.core.data.createManager('TestDataManager');
var model = manager.createModel({
  name: 'TestModel',
  schema: {
    id: {
      id: true,
      type: 'integer'
    },
    message: {
      type: 'number'
    }
  }
});

for (var i = 0; i < 1000; i++) {
  infoItems.unshift(model.create({id:i, message:i}));

  if (infoItems.length > 10) {
    infoItems.pop();
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment