Utilization of memory efficiently is vital for any application’s performance. Even all modern development environments provide automatic memory management capability though Garbage Collection (GC) mechanism, we cannot completely rely on GC.
In several situations we create multiple objects and most the objects within the scope of the application, but we seldom use those objects. Even worse sometime we open database, network connections or file stream but do not close them. These mistakes eat up valuable system memory resulting degradation of application performance.
Even those there are multiple memory profiling tools available in the market we can still check how our application is performing in context of memory utilization by creating our own small utility class.
Let’s try to develop a class that can be hooked to any of the application which keeps on checking our applications heap memory utilization in every 30 second interval.
To develop this utility we need to take care three important Java classes:
java.lang.Runtime– Every Java application has a single instance of class Runtime that allows the application to interface with the environment in which the application is running. The current runtime can be obtained from the getRuntime method.
java.util.TimerTask– A task that can be scheduled for one-time or repeated execution by a Timer.
java.util.Timer– A facility for threads to schedule tasks for future execution in a background thread. Tasks may be scheduled for one-time execution, or for repeated execution at regular intervals.
Cloud Computing Overview:
Cloud computing is an emerging IT delivery model that uses the internet and central remote servers to maintain data and applications. Cloud computing allows consumers and businesses to use applications without installation and access their personal files at any computer with internet access. This allows for much more efficient computing by centralizing storage, memory, processing and bandwidth. In general, cloud computing customers do not own the physical infrastructure, instead avoiding capital expenditure by renting usage from a third-party provider. They consume resources as a service and pay only for resources that they use. It’s like Gmail Vs Microsoft Exchange. In gmail you don’t need server and storage, you don’t need technical team to keep it up and running and you don’t need to do upgrades. When you use any application that runs in cloud you just login customize it and start using. Read more…