-
Notifications
You must be signed in to change notification settings - Fork 10
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
ObservableItemが使用するメモリ量が多い #247
Comments
fukudayasuo
pushed a commit
to hifive-labs/hifivemain
that referenced
this issue
Sep 26, 2013
ObservableItemのコンストラクタを作成し、各ObservableItem共通のものはObservableItem.prototypeに持たせるようにリファクタしました。
ghost
assigned fukudayasuo
Sep 26, 2013
今までObservableItemそれぞれのコンストラクタを作っていたものを、ObservableItemクラスを作成して共通のものをprototypeに持たせるようにしました。 内部ではそれぞれのコンストラクタを作成してObservableItemのインスタンス作成に使用していますが、外から参照はされません。 以下のコードでObservableItemによるメモリの使用量を測定したところ、3.06MB→1.00MBに減りました。 // 1000個のObservableItemを作成してview.bind()
$('body').append( ' <div id="result" data-h5-loop-context="data"> <div data-h5-bind="message"></div> </div>');
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);
} |
fukudayasuo
pushed a commit
to hifive-labs/hifivemain
that referenced
this issue
Sep 26, 2013
hasOwnPropertyなものと、schemaとschemaInfoの中身をコピーするようにしました。
fukudayasuo
pushed a commit
to hifive-labs/hifivemain
that referenced
this issue
Sep 26, 2013
_originModelを使用するのをやめて_modelは常に生成時のDataModelが格納されるようにしました。削除されたかどうかは_isRemovedプロパティを追加してそれを見るようにしました。
fukudayasuo
pushed a commit
to hifive-labs/hifivemain
that referenced
this issue
Sep 26, 2013
fukudayasuo
pushed a commit
to hifive-labs/hifivemain
that referenced
this issue
Sep 30, 2013
createObservable時にdepend.calcが呼ばれたときにthisの値がObservableItemではなく内部で使用しているDataItemになっていましたので、修正しました。 テストケースの追加もしました。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ObservableItemの作成するFWコードを見直す。
ObservableItemはDataModelと共通した処理を同じ個所で行うために、DataModelで作成するDataItemコンストラクタを利用しており、ObservableItemを作成するたびにDataItem生成のためのコンストラクタを作成し、ObservableItemからそのコンストラクタが参照できるようになっている。
そのため、ObservableItem1つにつきDataModel1つと同じくらいのメモリを使用していると考えられる。
とりあえず、ObservableItemを作るときにDataItemコンストラクタを作成して使用するのはそのままにして、そのコンストラクタがObservableItemから参照できない(使いきり)になるようにする。
The text was updated successfully, but these errors were encountered: