Memory Management In Javascript
Memory management is always a priority in pretty much any programming language you would want to use. In the lower level languages such as C, there are a number of functions which help you manage the memory your application uses, but they are not the easiest to use. Some of the more modern programming languages such as Python, Ruby, Perl, and of course the subject of this article, Javascript all have a built in feature called garbage collection.
Garbage collection essentially means that the languages compiler will automatically free the memory being occupied by unused variables and objects, but there is no telling when this could occur. It is purely down to the compiler to decide when the garbage collection process should be initiated.
When it comes to programming with Javascript, the thought that you do not have to deal with how much memory is being used by a particular object or variable, can make life a whole lot easier. But that does not mean you should not keep it in mind when you are working on your application.
Take a look at the following code snippet:
var a = 123;
var b = "azerty";
Looking closely at the above code you would think that all we are doing is creating two variables and assigning a value to each, but under the hood Javascript also automatically allocates memory for those two variables, and it does the exact same thing when you create an array or an object.
The biggest problem faced by any langauge is the simple fact that there is no way to tell when a certain piece of memory is no longer needed. For example, if you have initialized an array containing some phone numbers which only need to be displayed once, then it seems a waste of memory to have that array sit there and do nothing while the space it is occuping could be used by other parts of the application.
What you have to keep in mind is that computer you develop your applications on may be powerful and loaded with lots of memory, but the end users of your software may not have the same computing power at their disposal. This becomes more important with web applications which run through the users browser, which in itself could be using a fair slice of the computers memory depending on what it is doing.
As mentioned near the beginning of this article, there is no way to tell when the garbage collection process will kick in and free the unused memory, but you as the programmer can help things along by being a little more dilligent with your variables and objects creation. As an example, if you create an application using Javascript and find that you have created several variables which the software actually ends up not using, then remove them.
Likewise, if you only use a variable or object once in your application and find you no longer need to use them, then set its value to null so it will use less memory. Always keep memory management in mind no matter what language you end up working with.
other blog entries
Course Directory [training on all levels]
- .NET Classes
- Agile/Scrum Classes
- Ajax Classes
- Android and iPhone Programming Classes
- Blaze Advisor Classes
- C Programming Classes
- C# Programming Classes
- C++ Programming Classes
- Cisco Classes
- Cloud Classes
- CompTIA Classes
- Crystal Reports Classes
- Design Patterns Classes
- DevOps Classes
- Foundations of Web Design & Web Authoring Classes
- Git, Jira, Wicket, Gradle, Tableau Classes
- IBM Classes
- Java Programming Classes
- JBoss Administration Classes
- JUnit, TDD, CPTC, Web Penetration Classes
- Linux Unix Classes
- Machine Learning Classes
- Microsoft Classes
- Microsoft Development Classes
- Microsoft SQL Server Classes
- Microsoft Team Foundation Server Classes
- Microsoft Windows Server Classes
- Oracle, MySQL, Cassandra, Hadoop Database Classes
- Perl Programming Classes
- Python Programming Classes
- Ruby Programming Classes
- Security Classes
- SharePoint Classes
- SOA Classes
- Tcl, Awk, Bash, Shell Classes
- UML Classes
- VMWare Classes
- Web Development Classes
- Web Services Classes
- Weblogic Administration Classes
- XML Classes
- Linux Fundaments GL120
9 December, 2024 - 13 December, 2024 - RED HAT ENTERPRISE LINUX AUTOMATION WITH ANSIBLE
2 December, 2024 - 5 December, 2024 - Introduction to C++ for Absolute Beginners
16 December, 2024 - 17 December, 2024 - Fast Track to Java 17 and OO Development
9 December, 2024 - 13 December, 2024 - Microsoft Azure AI Fundamentals (AI-900T00)
25 November, 2024 - 25 November, 2024 - See our complete public course listing
did you know? HSG is one of the foremost training companies in the United States
Our courses focus on two areas: the most current and critical object-oriented and component based tools, technologies and languages; and the fundamentals of effective development methodology. Our programs are designed to deliver technology essentials while improving development staff productivity.
An experienced trainer and faculty member will identify the client's individual training requirements, then adapt and tailor the course appropriately. Our custom training solutions reduce time, risk and cost while keeping development teams motivated. The Hartmann Software Group's faculty consists of veteran software engineers, some of whom currently teach at several Colorado Universities. Our faculty's wealth of knowledge combined with their continued real world consulting experience enables us to produce more effective training programs to ensure our clients receive the highest quality and most relevant instruction available. Instruction is available at client locations or at various training facilities located in the metropolitan Denver area.
Upcoming Classes
- Linux Fundaments GL120
9 December, 2024 - 13 December, 2024 - RED HAT ENTERPRISE LINUX AUTOMATION WITH ANSIBLE
2 December, 2024 - 5 December, 2024 - Introduction to C++ for Absolute Beginners
16 December, 2024 - 17 December, 2024 - Fast Track to Java 17 and OO Development
9 December, 2024 - 13 December, 2024 - Microsoft Azure AI Fundamentals (AI-900T00)
25 November, 2024 - 25 November, 2024 - See our complete public course listing
consulting services we do what we know ... write software
The coaching program integrates our course instruction with hands on software development practices. By employing XP (Extreme Programming) techniques, we teach students as follows:
Configure and integrate the needed development tools
MOntitor each students progress and offer feedback, perspective and alternatives when needed.
Establish an Action plan to yield a set of deliverables in order to guarantee productive learning.
Establish an Commit to a deliverable time line.
Hold each student accountable to a standard that is comparable to that of an engineer/project manager with at least one year's experience in the field.
These coaching cycles typically last 2-4 weeks in duration.
Business Rule isolation and integration for large scale systems using Blaze Advisor
Develop Java, .NET, Perl, Python, TCL and C++ related technologies for Web, Telephony, Transactional i.e. financial and a variety of other considerations.
Windows and Unix/Linux System Administration.
Application Server Administration, in particular, Weblogic, Oracle and JBoss.
Desperate application communication by way of Web Services (SOAP & Restful), RMI, EJBs, Sockets, HTTP, FTP and a number of other protocols.
Graphics Rich application development work i.e. fat clients and/or Web Clients to include graphic design
Performance improvement through code rewrites, code interpreter enhancements, inline and native code compilations and system alterations.
Mentoring of IT and Business Teams for quick and guaranteed expertise transfer.
Architect both small and large software development systems to include: Data Dictionaries, UML Diagrams, Software & Systems Selections and more