logo separator

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

From Chris Miller chris.miller at kbcfp.com on Mon Nov 23 12:06:18 GMT 2009

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.

Chris






More information about the mkgmap-dev mailing list