#1 deepSizeOf primitives problem

v1.0 (example)
closed
nobody
None
5
2014-10-01
2013-02-12
br111an
No

Method deepSizeOf seems to have some strange results for primitives and the wrapper objects of those primitives.

double myDouble = 1;
System.out.printf("double\n");
System.out.printf("sizeOf %d\n", SizeOf.sizeOf(myDouble));
System.out.printf("deepSizeOf %d\n", SizeOf.deepSizeOf(myDouble));

float myFloat = 1;
System.out.printf("float\n");
System.out.printf("sizeOf %d\n", SizeOf.sizeOf(myFloat));
System.out.printf("deepSizeOf %d\n", SizeOf.deepSizeOf(myFloat));

Double myDoubleObject = 1d;
System.out.printf("Double\n");
System.out.printf("sizeOf %d\n", SizeOf.sizeOf(myDoubleObject));
System.out.printf("deepSizeOf %d\n", SizeOf.deepSizeOf(myDoubleObject));

Float myFloatObject = 1f;
System.out.printf("Float\n");
System.out.printf("sizeOf %d\n", SizeOf.sizeOf(myFloatObject));
System.out.printf("deepSizeOf %d\n", SizeOf.deepSizeOf(myFloatObject));

double
sizeOf 24
deepSizeOf 200
float
sizeOf 16
deepSizeOf 192
Double
sizeOf 24
deepSizeOf 200
Float
sizeOf 16
deepSizeOf 192

Discussion

  • Marco Rosi

    Marco Rosi - 2014-07-08

    SizeOf.sizeOf (and the underlying java API) works on Object, when you pass a primitive type to sizeOf() java automagically wraps it into the corrisponding Object. This is the so called autoboxing (http://docs.oracle.com/javase/tutorial/java/data/autoboxing.html)

     
  • Marco Rosi

    Marco Rosi - 2014-10-01
    • status: open --> closed
    • Group: --> v1.0 (example)
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks