Open netpro2k opened 13 years ago
Thanks for the investigation! I'll look into this and get back to you!
+1 for garbage collector.
I started using xcode Instruments and saw, that most of the elements created by Kranium are not garbage collected and produce memory leaks. i.e. the todolist in the kranium-demo. Every time you add a todo, all tableviewrows+1 are added to the living objects. 4,9,15,22,30 etc...
Yes, this is a major problem, and I have yet to come up with a viable solution. I don't see how this could possibly be solved elegantly in the JS context. There is some research being done on WeakMaps (https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/WeakMap), which could help, but they're very very far from done yet.
I'm currently working on Kranium 0.2, and what I think I'll do there is to only make elements queryable if the developer explicitly says so, through setting the queryable
property to true
when creating the element. Of course, we'd still have to make sure any queryable elements were properly dereferenced when removed.
Thats a great Idea. Querying is "just" a nice-to-have feature for me. I love the kss-styling most. Without the need to rebuild the entire project like with standard-jss...
When do you think to finish the new version? I'm getting troubles with memory leaks and dont want to drop kranium.
Good! Then I'll proceed making querying opt-in :-)
For the status of Kranium 0.2 and its Ti SDK 1.8 support, please see https://github.com/krawaller/kranium/issues/12
Please if anyone have solution for memory leaks in version 1.4 place it here. This is very important for us also.
This is because they are retained in global cache for
K.elsByName
,K.elsById
, andK.elsByClassName
(and potentially elsewhere). For views, callingremove()
will remove them from these caches, but there is currently no way to do this for windows.I would think that calling
close()
on a window should remove it, and its subviews from the cache, so that they can be garbage collected.close()
should probably look something like this (not thoroughly tested)On a related note, it is unclear how to call
close()
from inside a KUI component, exapp.js
foo.js