Wednesday 9 November 2011

array ( memory problem ) in java .

I heard from some people that java deals with memory very beautifully . here i am not opposing them they all are learner and i am also in this class . but i find that some-times java is not correct in the matter of space saving .

why i am saying this .. see this article ..
http://jroller.com/rreyelts/entry/that_byte_is_about_7x

a great person .. Toby reyelts ..

here instruction like bipush and iconstant and ldc are not exclaimed at good level .
i will exclaim these three topics .

bipush & iconstant  :----
                                        iconstant is a part of bipush , and iconstant  is better than bipush but how , iconstant saves 1 byte in case of entering any data into machine by array , bipush takes 7 bytes to entering data into array and iconstant takes 6 bytes to enter data into array .

How 7 bytes are used by bipush :----
1.  1st byte is used dup the variable used in run time for passing data from operand stack to local array .
2.  2nd byte is used for finding the array .
3.  3rd byte is used for finding the index in array .
4.  4rth byte is used for passing the value .
5.  used for bastore .
6.7. two bytes are used for passing the operand and passing the value  .

how 6 bytes are used by iconstant :----
1.....5 every thing is same .
6,7 are converted to 6 and both things are passed only in one instruction .

so think about this that for passing one byte you have to use 7 bytes , so at this point java makes somee mistake that they did not create some instruction to handle the data or the array .

ldc :----
            ldc is a instruction used for loading values form run time constant pool .
there are 3 types of ldc .
1.  ldc  :-- used for small ranges .
2.  ldc_w  :-- used for ranges like int and float .
3.  ldc2_w  :-- used for ranges like long and double .


No comments: