Modify ↓
Opened 4 years ago
Closed 4 years ago
#20830 closed enhancement (fixed)
Reduce heap size of org.openstreetmap.josm.data.osm.Node by 8 bytes
Reported by: | simon04 | Owned by: | simon04 |
---|---|---|---|
Priority: | normal | Milestone: | 21.05 |
Component: | Core | Version: | |
Keywords: | heap profiling intellij yourkit | Cc: |
Description
We can save 8 bytes for each org.openstreetmap.josm.data.osm.Node
instance by moving the mappaintCacheIdx
from OsmPrimitive
to AbstractPrimitive
due to Java's memory layout alignment.
BEFORE org.openstreetmap.josm.data.osm.Node object internals: OFFSET SIZE TYPE DESCRIPTION VALUE 0 16 (object header) N/A 16 8 long AbstractPrimitive.id N/A 24 4 int AbstractPrimitive.version N/A 28 4 int AbstractPrimitive.changesetId N/A 32 4 int AbstractPrimitive.timestamp N/A 36 2 short AbstractPrimitive.flags N/A 38 2 (alignment/padding gap) 40 8 User AbstractPrimitive.user N/A 48 8 String[] AbstractPrimitive.keys N/A 56 2 short OsmPrimitive.mappaintCacheIdx N/A 58 6 (alignment/padding gap) 64 8 StyleCache OsmPrimitive.mappaintStyle N/A 72 8 DataSet OsmPrimitive.dataSet N/A 80 8 Object OsmPrimitive.referrers N/A 88 8 double Node.lat N/A 96 8 double Node.lon N/A 104 8 double Node.east N/A 112 8 double Node.north N/A 120 8 Object Node.eastNorthCacheKey N/A Instance size: 128 bytes Space losses: 8 bytes internal + 0 bytes external = 8 bytes total
-
src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
diff --git a/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java b/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java index 591048789..47262617a 100644
a b public abstract class AbstractPrimitive implements IPrimitive { 135 135 */ 136 136 protected volatile short flags = FLAG_VISIBLE; // visible per default 137 137 138 /** 139 * The mappaint cache index for this primitive. 140 * This field belongs to {@code OsmPrimitive}, but due to Java's memory layout alignment 141 */ 142 protected short mappaintCacheIdx; 143 138 144 /*------------------- 139 145 * OTHER PROPERTIES 140 146 *-------------------*/ -
src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
diff --git a/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java b/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java index 764e4e1d3..496751f98 100644
a b public abstract class OsmPrimitive extends AbstractPrimitive implements Template 145 145 * MAPPAINT 146 146 *--------*/ 147 147 private StyleCache mappaintStyle; 148 private short mappaintCacheIdx;149 148 150 149 @Override 151 150 public final StyleCache getCachedStyle() {
AFTER org.openstreetmap.josm.data.osm.Node object internals: OFFSET SIZE TYPE DESCRIPTION VALUE 0 16 (object header) N/A 16 8 long AbstractPrimitive.id N/A 24 4 int AbstractPrimitive.version N/A 28 4 int AbstractPrimitive.changesetId N/A 32 4 int AbstractPrimitive.timestamp N/A 36 2 short AbstractPrimitive.flags N/A 38 2 short AbstractPrimitive.mappaintCacheIdx N/A 40 8 User AbstractPrimitive.user N/A 48 8 String[] AbstractPrimitive.keys N/A 56 8 StyleCache OsmPrimitive.mappaintStyle N/A 64 8 DataSet OsmPrimitive.dataSet N/A 72 8 Object OsmPrimitive.referrers N/A 80 8 double Node.lat N/A 88 8 double Node.lon N/A 96 8 double Node.east N/A 104 8 double Node.north N/A 112 8 Object Node.eastNorthCacheKey N/A Instance size: 120 bytes Space losses: 0 bytes internal + 0 bytes external = 0 bytes total
Attachments (0)
Note:
See TracTickets
for help on using tickets.
In 17849/josm: