I have a java application that is used to monitor an external hardware entity. When I run this application and leave it idle, on the Windows Task Manager, I can see the javaw.exe process memory usage goes steadily increasing(by 4kb)
I have used a memory profiler on my application, and there are no leaks in it. Neither are there any objects that are being created but not being freed.
However, when I minimize and maximize the application, the task manager shows a reduced amount of memory usage!! Is it possible that windows is not cleaning up the memory while my application is running, even though the garbage collector is performing clean-up regularly?
I am currently using java 1.4.2_08 with Windows Xp SP2.
You could be looking at the wrong column in Windows Task Manager.
By default, it shows a column "memory usage". That column is telling you the amount of physical memory used by the process. It is not very useful to a developer. It certainly does not tell you much useful information about the Java heap.
You want the column "VM Size", which is not displayed by default. This column tells you how much virtual memory is used by the process. This corresponds more closely to the memory used by the Java heap (and code, stack etc.).
Even when you're looking at the VM Size column, you still have to remember that Java is a garbage-collected language, so there's less connection between the amount of live data in your application and the amount of memory used by the Java process.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Joined: Nov 30, 2004
Thanx Peter. My query is a little different.
Well, the memory usage that is displayed by task manager is slightly different from the heap usage, but my query is when my application is not performing any action, why does this memory go up on its own?
And also, when I do a minimize-maximize cycle, the memory indication in this field of the task manager drops down!! So is there some VM/GC option that I can configure to avoid this memory rise?
Joined: Oct 30, 2001
Java does stuff in the background. Also, if you are looking at Memory Usage, not VM Size like I advised, then the figure will vary depending on how much of the application is in physical memory. That's of little or no interest to you as a developer, in 99.9% of cases.
Note that minimising and maximising the application may very well change how much of it is stored in physical memory. But again, *you don't care*.
Does the memory figure (whichever) go up and up forever? If so, you have a real problem. If it goes up for a while, then stabilises, you're just seeing the effect of something Java or the OS is doing in the background. Don't worry about that - move on.
I have a java application that is used to monitor an external hardware entity. When I run this application and leave it idle,
By leave it at idle do you mean it is not monitoring anything? The monitoring Thread is doing what? Whats the longest period you have watched with the memory increasing? Are you starting with the default memory settings? Bill
It seems like GUI application. There may be some windows GUI events even when there is not apparent activity.
The memory usage in task manager is actually the working set size, which is trimmed when application is minimized (many other applications behave like this).
Working set is not the same as amount of allocated or used memory. But it should not grow when application is totally idle (shrinking is possible).
Joined: Aug 03, 2004
If there is any memory access each 600ms, the application is definitely not idle. And in such situation it is normal that working set size is changing (any memory access can trigger it) - especially such small changes. GC will probably make bigger changes.
Memory usage (working set size) drop when minimizing is only virtual.