So we all know that Java Heap is a crucial resource, lack of which will kill your application. Naturally you will want to monitor the heap usage. Bur surprisingly it is not very straight forward to measure the heap usage of your JVM unless you have a modern APM (Application Performance Management) tool implemented. To make things worse, in Windows world, the memory you see in Windows Task Manager (a solid tool by btw) is NOT the same as the JVM heap size.
For example, let’s say you have set maximum java heap at 3GB. But it is quite possible that the memory shown by Task Manager be higher (much higher at times), say 3.5 gb or 4 gb. You can pull you hair trying to figure out where that extra memory utilization came from, or you can read rest of this article and put an end to the mystery.
Generally speaking, here is the reason memory shown by the Task Manager is more than the Heap: The memory shown in Task manager is the entire Memory footprint of the JVM and NOT just the Java Heap of the JVM. Note that the JVM is just an another process as far as Windows is concerned.
While Unix/Linux is the most popular OS for hosting enterprise java applications, there are still significant amount of applications deployed on Windows Platform. If your application is running on a Windows box, you ought to know how to get around Windows in order to support your application effectively.
In this piece, I’m going to share with you 10 tricks every Java Developer should know. I tested these in Windows 2008 R2. But it should work on most Windows flavors. Let’s get right to it.
1. Find the full command line of your java application
In Unix/Linux, if you need to see the full command line of your application, you can simply use ‘ps –ef’. For example,
ps –ef | grep <my application>
Alas! There is no ‘ps’ in windows. So, how do you do this? Say hello to Windows Task Manager.
The verdict is in. Virtualization is the future. If you are still running your applications on bare metal, you are missing out on tons of benefits, or even hurting your business. Virtualization is a software tech that lets you run multiple operating systems and applications on a physical server by abstracting the hardware underneath. Among several Virtualization software makers, the following are considered leaders:
Let’s dive in to 5 reasons why you can’t afford NOT to virtualize (not necessarily in any order)
Yes, AppDynamics is awesome for Application monitoring – Java Heap, deep transaction tracing, tons of out-of-the-box framework monitoring (JDBC,WebService etc) and the list goes on. But do you know Appdynamics can be used to effectively monitor Servers too, whether it is virtual or physical? When I say server, I mean the host operating system such as RedHat Enterprise Linux, Windows 2012, Solaris etc. Let me show you how you can do this.
Enter AppDynamics Machine Agent
While Java can be monitored using a Java Agent, a Server can be monitored using a special type of agent called Machine Agent. You will have to have license to run these agents (When you purchase Application agents, typically AppDyanmics throws the same number of Machine Agents, and so you should be good in terms of additional cost). If you are not sure about your present licensing situation, click on ‘licensing’ in your Controller UI as shown below.
Unlike Application agents which run inside the JVM/CLR, Machine agent is a standalone Java program that runs on the host operating system. It collects hardware metrics and sends them to Controller (once a minute). A user can view these metrics via Controller UI. Pretty simple, hah?
Occasionally you will want to know how many lines are there in a file. In unix world, you can use the nifty ‘wc’ command
wc –l < filename>
In Windows Powershell you can use the built in cmdlet named ‘measure-object’. It is pretty powerful.
For counting lines in a file, use the following command
Get-content <filename> | Measure-Object –Line
If you want to learn more about measure-object,
Help Measure-Object –detailed
If you come from the unix world, there is a nifty command you can use to ‘sleep’ in shell scripts. What about windows powershell?
You can use the command start-sleep just like you use ‘sleep’ in unix.
You can use either seconds or milliseconds as shown below:
I am sure you have gone through this: You see an interesting article in a website and decide to print it to take a closer look. The article itself is about a page or two in length. But what happens when you go to the printer to collect it? That’s right. It prints pages and pages of data, mostly ads and even more annoying – blank pages.
With Chrome, there is a neat feature that lets you avoid those annoying ads and blank lines.
Check this out. Here is a sample page that you see online:
Now when you print this article (either using Ctrl-P or using the chrome menu to choose ‘print’, you will see the following page
How to clear passwords from Windows Vault (Credentials Manager) ?
At times, you want to get rid of passwords stored in Windows vault (primarily if you are in a corporate environment where you have frequently change the password).
If you keep getting locked out of your corporate environment mysteriously, clearing windows vault passwords might fix it.
Go to Control Panel and type ‘vault‘ in the search box at the right. It should bring up ‘Credentials Manager’.
If you are using Windows 8.X, go to the start screen and type ‘credentials’ to bring up credentials manager.
Scroll down the ‘Generic Credentials‘ and delete the ones you don’t need them.
When a folder is hidden in Windows, you cannot see it in Windows explorer. However you can navigate to it if you access the full path name (either in Windows Explorer or via command line). You can also use “dir /a” command to show hidden files. When you pull up the properties for the hidden folder, you wil see the ‘hidden’ check box is set and grayed out. You can use the ‘attrib’ command to unhide the folder.
If selecting ‘Show hidden files, folders and drives’ under View -> Folder Options don’t do the trick, try this command:
From Windows Command prompt
attrib -H -S <full path of the folder name> /D /S
-H : Clears Hidden attribute
-S : Clears System attribute
/D : Processes folders in addition to files
/S : Processes folders and files in subfolders recursively.
Thank God there is command line.
Have you ever tried to find out the entire command line arguments for the ‘java’ command that starts your application in Windows ? Have you ever tried to find out which files or DLLs are opened by your Java Application in Windows ? The Windows Task Manager is OK but it does not give you the deeper insight that you would need to answer the above questions. Welcome to Process Explorer.