Home     |      Learn AJAX     |      Forum     |      Register     |      Submit Resource     |      Submit Article      |      Contact Us

Home JavaScript
 

JavaScript Garbage Collection

 

JavaScript and Ajax based applications could be a data hog that could drag the browser and even the local gadget to a halt. The browser cache practices of JavaScript and Ajax could easily drag the browser especially if the local gadget does not have the processing power to hold the cached data effectively. This could happen since JavaScript and Ajax are practically online applications that deal with data consistently. But this challenge could be easily dealt with when developers control cache in their application.


But aside from controlling cached data, developers have to deal with another process that could slow down the application: references through event handlers. References are a good way to increase the efficiency of the application.


Just like a browser cache, the application will help the browser save a small chuck of data for future reference but the main difference of reference in event handlers is it creates links. This is even smaller but it could still clog the application and will slow down the browser. If the data processed is too large, references might even halt the application altogether.


To deal with that problem, garbage collections should be implemented. This can easily remove the reference from the browser so that the application could “breath” and implement the expected functions faster.


Disposing Practices

The easiest way for JavaScript to implement garbage collection automatically is to close the browser. Every major browser still keeps some of the cached data even when they browser was closed but when it comes to references, the previous data will be completely gone when the browser is back online.


But you cannot tell that to users midway in the application and automatically closing the browser is just annoying.


A smarter approach for developers is to attach an array to events so that it could act as garbage collectors midway the application. Developers could freely clock when the array would implement garbage collection. This actually might slow down the application a little bit but the trade-off is worth it.


Clogging Up the Application

The challenge of clogging up the application unexpectedly is always there. The reference from events as well as cache from data processing could create a problem without the developers knowing it.


Controlling cache as well as running arrays has to be implemented while the application is being developed. Implementing them after the application is done could easily create problems for developers not to mention the expected downtime for “upgrades.”


Keeping it Simple

Garbage collection in JavaScript is another reminder for developers to simplify the process in Ajax based application. One of the ways that reference from events could clog the system when the developer creates parallel transactions with the events. This could easily slow down the system since the browser has to deal with data transactions frequently and aggressively.


For that reason, the only way to improve the application without problems in garbage collection would be to simplify the process. By creating functions that could be dealt with by major browsers, users can expect a better application without experiencing unexpected downtimes.



Read Next: Smart JavaScript Navigation



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links