Hello folks

AFAIK, there is no memory leak in using LazyLoader. Note LazyLoader for
JS files does not impose any specific format over the object you are
trying to load. It is not like require.js where dependencies live
forever, it is just a convenient way to synchronize several "add
<script> to DOM" operations. No more, no less (at least, from the JS
point of view, LazyLoader is able to load HTML external sources as well).

The loader does not keep a cache of objects, it only keeps a map to mark
already loaded resources in order to avoid the load process so the same
JS is not attached twice to the DOM.

The only thing we could add is some mechanism to allow detach <scripts>
elements from the DOM but this not even warranty you free the objects
created inside.

Take a look  at the code of LazyLoad, it's really straightforward:
https://github.com/lodr/gaia/blob/master/shared/js/lazy_loader.js

Hope it helps.
On 23/12/13 01:25, Prateek Jadhwani wrote:
On Sunday, December 22, 2013 6:16:03 PM UTC-5, Rick Waldron wrote:
On Sun, Dec 22, 2013 at 8:57 AM, Prateek Jadhwani
wrote:


Hello People,
 From the looks of the code, it seems that the js files LazyLoads the code
of the modules it needs. My question is does it get rid of the js files
that were LazyLoaded after its work is done, or does it stay in the memory.
Coz if it just keeps on adding every file, then it might cause some serious
performance problems.




Can you elaborate?



Rick
Hi Rick,

What I meant to ask was When you load a js file via Lazy Loading, does it stay 
in the memory for ever, or it gets cleared up when the object that was required 
from that file is deleted in garbage collection.

I have no idea how Lazy Loading works. So extremely sorry for my noob 
questions. I just know that Lazy Loading loads the files on demand. So rather 
than loading the file in the beginning of an app, with the help of Lazy 
Loading, it can be called when it is required.

Thanks
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g



________________________________

Este mensaje se dirige exclusivamente a su destinatario. Puede consultar 
nuestra política de envío y recepción de correo electrónico en el enlace 
situado más abajo.
This message is intended exclusively for its addressee. We only send and 
receive email on the basis of the terms set out at:
http://www.tid.es/ES/PAGINAS/disclaimer.aspx
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to