File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes sizeof for swing? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "sizeof for swing?" Watch "sizeof for swing?" New topic
Author

sizeof for swing?

Mandar Khire
Ranch Hand

Joined: Sep 11, 2007
Posts: 492

I know its old topic like old wine in new bottle. But i confuse so ask here...

I read article from www.javaworld.com
(Hardly understood something...need to more study for me)
After reading this article i search first in coderanch regarding

size-primitive-java
In that Jesper de Jong written last post

But note that a particular JVM implementation might use more memory for primitive types on the underlying platform. For example, on some processors working

with 32-bit integers is more efficient than with 8-bit bytes, so the JVM will actually use 32 bits for a variable of type byte. In your Java program however,

you will not notice this - there, a variable of type byte is always 8 bits, regardless of how the JVM represents it on the underlying platform.

&

There is no (easy) way to find out in a Java program how much memory is actually used for a primitive type of a certain size - those things are

implementation details of the JVM that your program is running on, which you're not supposed to be concerned with from inside your program.


After reading these 2 websites i try to understand oracle doc for primitive datatype
&
I use code which given in Java Tip 130: Do you know your data size?.
i find out:-
I use following lines one by one
1. Byte

output:-'before' heap: 543064, 'after' heap: 2143712
heap delta: 1600648, {class [[B} size = 16 bytes

oracle doc for JComponent

1.JButton

output:-'before' heap: 709648, 'after' heap: 99912096
heap delta: 99202448, {class javax.swing.JButton} size = 992 bytes

Question 1. What is heap delta?
Is it related to something memory-leaks-in-java-code

Question 2. size = 16 bytes or size = 992 bytes
what are they? It size which in jvm in my pc or some thing else?

Question 3.If i write code which contain almost all datatype & lots jcomponents, then for see whether each one using proper size or not, is there any chart or something similar to it.. so i can compare with it...
or is there way to check my code not using unnecessary size?

Question 4. I try to use winhex tool for RAM reading & try to run small code like create jpanel....
but it difficult to get learn how much actually jcomponent takes size in memory? Is there easy way?



Millions saw the apple fall, but Newton asked why.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sizeof for swing?