aspose file tools*
The moose likes Performance and the fly likes any class that is made up of byte array? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Performance
Bookmark "any class that is made up of byte array? " Watch "any class that is made up of byte array? " New topic
Author

any class that is made up of byte array?

Lilian Chase
Greenhorn

Joined: Jun 14, 2010
Posts: 24
[Edit: split from another topic. please start a new topic for your own questions.]

I have a related questions regarding the overhead and "components" of a Java class.

I ran my application through a profiler and I noticed a lot of byte arrays were created but I don't use byte arrays explicitly in my program.
So I was wondering if those arrays are created from other class that I maybe using.

I know String is made up of char array and integer fields to keep the value of offset, count and hash value.

My question is, Is there any class that is made up of byte array?

Thank you

( TS, I hope you don't mind that I'm using your thread for this. )


Jay Orsaw
Ranch Hand

Joined: Jun 14, 2011
Posts: 354

I dont mind extra questions the more questions the more we all learn. As for byte arrays i know i have a class that uses them, im not at my computer but i think it might have to do with graphics but again im not at home so dont go crazy on me :p. I would goto the api for the classes you use and check them out.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Lilian Chase wrote:
My question is, Is there any class that is made up of byte array?


You profiler should be able to show you what is referencing those byte arrays.


( TS, I hope you don't mind that I'm using your thread for this. )


There's no reason to do that. Please start your own threads in the future. Bear was kind enough to move this one for you.
Chris Hurst
Ranch Hand

Joined: Oct 26, 2003
Posts: 396

I could have a guess ;-) but the best way is jmap you have it with your JDK with it you can get a hwprof of your application, load it with visualVm again in the bin directory of your JDK and that will tell you where they all come from.


"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5
Rohan Dhapodkar
Greenhorn

Joined: Jun 27, 2011
Posts: 23
One of the best way is to
1. load heap dump with Eclipse MAT.
2. In the histogram view select char[] class
3. Right click ->'Show objects by class' -> 'By incoming references'

and then class references view will show you how many instances of char[] are referred by which class and their size.

I learned this hard way



[Thumbnail for mat - char[] class reference.JPG]

Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7029
    
  16

Lilian Chase wrote:My question is, Is there any class that is made up of byte array?

I believe that there's an option to have Strings use byte arrays with v7, but not exactly sure when.

I guess my question to you is: what would you do with the information? You probably can't change it.
If it's just to satisfy curiosity then knock yourself out, but I wouldn't spend too much time on it.

Winston


Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Winston Gutkowski wrote:
I guess my question to you is: what would you do with the information?


From the first post, it looks like "My profiler shows these things, but I don't know where they're coming from." If the proliferation of byte arrays is causing a memory problem, know which classes are referencing them can help drive a solution, e.g., "Hmm... they're all referenced by Fubars, and ... Eureka! I'm forgetting to remove Fubars from this here map when I'm done with them."
Chris Hurst
Ranch Hand

Joined: Oct 26, 2003
Posts: 396

I believe that there's an option to have Strings use byte arrays with v7, but not exactly sure when.

Its -XX:+UseCompressedStrings and its available in 6.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 7029
    
  16

Chris Hurst wrote:Its -XX:+UseCompressedStrings and its available in 6.

That's the chap. Cheers Chris.

Winston
Nikita Salnikov-Tarnovski
Greenhorn

Joined: May 02, 2012
Posts: 3
If you are looking for the cause of the memory leak, then do not use profilers. I have written a blog post about why this is not a very good idea. Use MAT or Plumbr for that.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Nikita Salnikov-Tarnovski wrote:If you are looking for the cause of the memory leak, then do not use profilers. I have written a blog post about why this is not a very good idea. Use MAT or Plumbr for that.


Contrary to what your blog asserts, those three "bold conditions" do in fact hold much of the time. There have been a few handfuls of times over the years when I've needed to track down a memory leak that wasn't evident simply from the specific behavior and visual inspection of the relevant code, and every single time, a profiler has made it obvious where the problem was in very short order. I have found this to be true with VisualVM, OptimizeIt, and possibly JProbe or JProfiler, though I can't recall, as well as with gdb for C programs.

I'm not saying your recomendatoin isn't valid, just that it's another approach to try, in addition to profilers, rather than as a wholesale "instead of."
Nikita Salnikov-Tarnovski
Greenhorn

Joined: May 02, 2012
Posts: 3
Jeff Verdegan wrote:There have been a few handfuls of times over the years when I've needed to track down a memory leak that wasn't evident simply from the specific behavior and visual inspection of the relevant code, and every single time, a profiler has made it obvious where the problem was in very short order. I have found this to be true with VisualVM, OptimizeIt, and possibly JProbe or JProfiler, though I can't recall, as well as with gdb for C programs.

I'm not saying your recomendatoin isn't valid, just that it's another approach to try, in addition to profilers, rather than as a wholesale "instead of."


Sure, YMMV. I have found that memory dump analysis gives results much quicker and with much less overhead for a production environment, than profilers. And when Plumbr works, then it is a way more preferable tool.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: any class that is made up of byte array?
 
Similar Threads
Confusion creating String
array?
Varargs and arrays - Mughal's mock exam, question 60
Sun Cirtification
Quick String to <char> Array Conversion