Is there a way to see the memory usage of NIO buffers? There is the non-heap memory section in JConsole, but I do not think this includes the NIO buffers?
Operating system is Linux (Ubuntu or CentOS) if that would matter.
regards,
Wim
Is there a way to see the memory usage of NIO buffers? There is the non-heap memory section in JConsole, but I do not think this includes the NIO buffers?
Operating system is Linux (Ubuntu or CentOS) if that would matter.
regards,
Wim
I have used this to monitor the Virtual and RSS memory and the amount of native threads:
for((i=0;;++i)) { echo $i ` grep VmSize /proc/21009/status | grep -o [0-9]* ` ` grep VmRSS /proc/21009/status | grep -o [0-9]* ` ` grep Threads /proc/21009/status | grep -o [0-9]* ` ; sleep 1 || break; } > data
It creates a space separated file which you can easily import into your favorite spreadsheet tool.
You need to replace 21009 with the process id of the java process you want to monitor, of course.
This does not fully answer my own question as I wanted to be able to have a look at just what NIO stuff has allocated, not all the memory used by the JVM, although this little script already proved me useful enough to see that there are no memory leaks in a program I was investigating.
It is worth noting that direct memory buffers only use as much physical memory as you use (to the next page size, typically 4K). They use virtual memory when created but the OS is smart enough not to allocate pages of physical memory (resident) until you use the pages in the direct memory buffer. This means the size of physical memory used can be smaller than the amount of memory you allocate (virtual). The physical/resident memory is the one you should care about.
The benifit of this is you can allocate a few MB buffer even if you only expect to use a few KB and it will only use the amount you use and if for some reason you need more, your program won t blow up. i.e. you don t have to get the size right and can fairly safely over estimate the size allocated.
Yes, from linux via the ps
command. Example:
ps x -o command,rss | grep java | grep latest | cut -b 17-
The output will be in KB.
You may be interested in a question I had a while back regarding Java, RSS and NIO buffers: Why does the Sun JVM continue to consume ever more RSS memory even when the heap, etc sizes are stable?
Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...
Check this, List<String> list = new ArrayList<String>(); for (int i = 0; i < 10000; i++) { String value = (""+UUID.randomUUID().getLeastSignificantBits()).substring(3, ...
I am in the middle of solving a problem where I think it s best suited for a decorator and a state pattern. The high level setting is something like a sandwich maker and dispenser, where I have a set ...
I have been trying to execute a MS SQL Server stored procedure via JDBC today and have been unsuccessful thus far. The stored procedure has 1 input and 1 output parameter. With every combination I ...
I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...
If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...
I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....
I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...