This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

sizeof for swing?  RSS feed

 
Mandar Khire
Ranch Hand
Posts: 575
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?


 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!