logo separator

[mkgmap-dev] [PATCH v1] make DP filter avoid removing pointslocated at nodes

From Mark Burton markb at ordern.com on Mon Nov 23 12:42:44 GMT 2009

Hi Chris,

On Mon, 23 Nov 2009 12:06:18 +0000 (UTC)
Chris Miller <chris.miller at kbcfp.com> wrote:

> MB> But does it increase the size of a Coord? I admit to not having
> MB> actually measured the size but I've added a boolean to an object
> MB> that already contains a boolean. If the Java implementers are smart
> MB> they would be stored as single bits rather than bytes/shorts/words.
> MB> Perhaps someone who knows about this could comment.
> 
> I haven't looked at the code/patch in question, however in most/all the VMs 
> I'm aware of a boolean will use 4 bytes (same as an int). Multiple booleans 
> aren't packed, unless they're stored in an array (where they're packed one 
> per byte). There's also the possibility of word alignment causing additional 
> bytes to be wasted, but that depends on whether it's a 32 or 64 bit VM, and 
> the number and types of other fields in the same class.
> 
> If you need to pack bits as tightly as possible there's java.util.BitSet, 
> but that only starts to make sense if you have a large number of booleans. 
> If you only have a few of them, custom bit manipulation would be required 
> to mimise the memory impact.

java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)

Just tried a quick test and on an Intel box I am seeing 1 byte per
boolean, not 4. As the object sizes are rounded to multiples of 8, it
looks like a case of buy one, and get 7 for free!

Cheers,

Mark



More information about the mkgmap-dev mailing list