![]() |
|
|
|
|
|
|
2
2nd November 23:33
External User
Posts: 1
|
As toton put it so eloquently,
i think you mean objects. basically, no. and you're probably not going to get as much speed-up or space savings as you might think. even if not allocated contiguously, the copying garbage collector is likely to organize them to be contiguous after the first GC. the extra indirect from the array of pointers is pretty cheap. if you *really* want to do something like this, you can allocate an int[] and logically partition it in the code yourself, but this is VERY nasty, breaks the OO philosophy, etc. same deal. the best to could do is create a couple variables with the "fields" and manually inline the code in the method. at least from the language perspective, all Java objects are heap-allocated and accessed through a direct reference (pointer). i presume a virtual machine would be allowed to break these rules in cases it can prove equivalence, but i doubt this is used much if at all. i believe VM implementers instead focus on making the memory manager fast, fast, and fast. -- Peter Dillinger http://www.peterd.org |
|
|
|