Wait! Looks like we don't have enough information to add this to bug database. Please follow this template bug format
Template - ItemdId - Memory leak
Sencha Touch version tested:
Platform tested against:
There is a memory leak if you use itemId in template elements the memory . Ext.dom.Element.cache increase every time you show a template.
- Create a list that use template (tpl:String/String/Ext.Template/Ext.XTemplate) for items
- Create a store with many elements
- Write template using some html elements (an heavy elements is better)
- Add to template elements an attribute itemId
- get this element by item.element.down
- call "store.load()" continuously
Memory will be realeased by garbage collectors
- The result that was expected:
The result that occurs instead:
Memory will be not released!
Ext.dom.Element.cache grow up!
The JS garbage collector releases memory at random times how long of a period are you testing over?
I would also suggest using the Chrome developer tools profile panel to check for leaks.
FYI when you take a heap snapshot in chrome dev tools it does initiate the garbage collector.
It would help expedite this issue if you put together a fiddle and verify that it reproduces this behavior.
I investigated better this behavior:
I must remove it from cache
- I run a query on html element (in my case on element of an item template)
- senchaTouch creates an "Ext.dom.Element" for the query result element
- this element will be cached in "Ext.domElement.cache"
- nobody never will remove it.
am I doing something wrong?
You should not have to. Can you provide a fiddle that reproduces this behavior.
tap button many times and watch the browser console.
Thanks for the test case. I have verified that it reproduces the issue you are reporting. I am unfamiliar with the itemId attribute. For what purpose are you using it?
I think the problem is caused by the query that creates an Ext.Element independently from the field used for the query.
However I use itemId like Id: I use this field for have an identifier for every Component that I need to search. is it wrong? is there a better way?
Well id's are usually intended to be unique within a html document. The way you have it set up each list item will have the same id. I don't think it is necessary as you can use component query to retrieve your list based on its itemId (itemId: 'myList') and the getInnerItems() method to get access to the list items.
Check out the console results on the following fiddle: https://fiddle.sencha.com/#fiddle/4di