-
Sencha User
Memory warnings and application crash
Hi all,
When I run my app on iPad the app crashes after giving memory warnings.
In the app I have to search a record in store. for this I am using filterBy() function. the search works fine 2-3 times and gives the result correctly. but after that keeping search continue I am started getting memory warning and application crashes.
Please help
-
Hi - Post your code please.
-
Sencha User
hi,
Thanks for quick response. here is code fragment
var categoryStore = Ext.create('Ext.data.Store', {
model: 'MyStore.model.Products',
proxy: {
type: 'ajax',
url : 'app/data/' + record.get('categoryId') +'.json' ,
reader: {
type: 'json',
rootProperty: 'items'
}
},
autoLoad: true
});
categoryStore.on('load', function() {
categoryStore.each(function(rec) {
(rec.products()).filter('productId', sProductId);
productRecord = (rec.products()).queryBy(function(record) {
if(record.get('productId') == sProductId) {
console.log('Matched Product Id: ' + record.get('productId'));
searchRecord = record;
return true;
}
});
});
if(searchRecord) {
productInfoStore = searchRecord;//used as store in selectFinish
if(searchRecord.get('productId') == "") {//product can not be added to cart
Ext.getCmp('addToCart').hide();
Ext.getCmp('updateCart').hide();
Ext.getCmp('productSizeList').hide();
}
else {
Ext.getCmp('addToCart').show();
Ext.getCmp('updateCart').hide();
Ext.getCmp('productSizeList').show();
}
Ext.getCmp('productInfo').getTpl().overwrite(Ext.getCmp('productInfo').element, searchRecord.data);
//Ext.getCmp('productDetailTitlebar').setTitle('Product Detail: #' + searchRecord.get('patternNumber'));
if(searchRecord.get('hResImgUrl')!="noImage"){
Ext.getCmp('productDetailImage').setHtml('<img src="' + searchRecord.get('bgImgUrl') + '">');
}else{
Ext.getCmp('productDetailImage').setHtml('<div class="product"><img src="' + searchRecord.get('bgImgUrl') + '"></div>');
}
console.log('SearchRecord: ' + searchRecord.get('patternNumber'));
var availableFinish = searchRecord.availableFinish();
var options =[];
availableFinish.each(function(record) {
options.push({text: record.get('text'), value: record.get('value')});
});
Ext.getCmp('selectFinish').setOptions(options);
if(Ext.getCmp('selectFinish').getStore().getAt(0).get('text') == '') {
Ext.getCmp('selectFinish').hide();
}
else {
Ext.getCmp('selectFinish').show();
}
Ext.getCmp('productSizeList').setStore(searchRecord.availableFinish().getAt(0).availableSizes());
if(Ext.getCmp('productSizeList').getStore().getCount() > 0) {
Ext.getCmp('productSizeList').select(0, true, false);
}
me.getHome().setActiveItem(me.listingDetail);
}
});
-
I would check image sizes and possible memory issues.
Also are you cleaning out the dom? Run your app in safari on the desktop or chrome and inspect the dom.
Make sure its not growing as you do searches.
This code block runs on the store load - does it only run once?
you can check number of dom elements with this code in the console - document.getElementsByTagName("*").length
A lot of getCmp() use which isnt ideal - if this class needs to know about a lot of components then set references on this class as the components are constructed. The you will have a reference to the components instead of having to search for them. References get set once during construction.
-
Sencha User
Thanks for your reply. It was realy helpfull.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules