aspose file tools*
The moose likes Performance and the fly likes visualvm is reporting 'byte[]' and 'char[]' as classes in memory profiler Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "visualvm is reporting Watch "visualvm is reporting New topic
Author

visualvm is reporting 'byte[]' and 'char[]' as classes in memory profiler

Dan Peters
Greenhorn

Joined: Sep 07, 2009
Posts: 2
Hello,

I have a tomcat web app that is eating up more memory than I would like. I'm profiling tomcat with visualvm, and in the memory profiling section, the top two 'classes' it's showing me are 'byte[]' and 'char[]'. I haven't done a lot of profiling before, so this is a bit confusing. Those seem to be references to an array of bytes or chars respectively, I'm just confused as to why the profiler is showing me those instead of actual class names.

As a bit of background, my application is using the spring MVC web framework. I have JSP pages on the frontend, and I'm using Hibernate with a mySQL DB for persistent objects on the back. As an example, when I go to an 'edit' page, a backing object is provided, and the heap jumps like 100MB. The object itself isn't holding anywhere near that amount of data, nor is it referencing other objects that would take that much memory as near as I can tell, so I'm stumped as to what's happening. I confess that the inner workings of hibernate and spring are somewhat of a mystery to me, so maybe I'm missing something there.

So in short, can anyone comment on why the profiler is reporting arrays of bytes and chars as classes in the memory profiler? Any other related comments are of course welcome as well!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41574
    
  54
It's simple - in Java, arrays are objects. You even allocate them using the "new" operator. As a corollary, byte[] and char[] would be the "class names" to display (putting that in quotes, because that's just a conceptualization).


Ping & DNS - my free Android networking tools app
Dan Peters
Greenhorn

Joined: Sep 07, 2009
Posts: 2
thanks for the reply. Of course, that makes sense! I was still thinking about arrays from a C++ perspective without realizing it. I searched through the code for declarations of 'byte[]' or 'char[]' and only hit one instance of 'byte[]', which wasn't related to the object I'm providing to back the form, and no declarations of 'char[]' in the entire code base! I'm baffled by this. Any suggestions of how I can narrow down on where these array objects are coming from?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
One of the great things about Java is you can get the source code! Look at the String class for example:



A String object must have a char[] to hold the characters.

Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: visualvm is reporting 'byte[]' and 'char[]' as classes in memory profiler