Commit 70bf737
Look a wrapper class up without boxing its class id
Whether an instance wraps a primitive is a lookup by class id, and that
lookup went to a Map<Long, PrimitiveWrapperClass>, so hashing the key
boxed the id of every instance dump, LOAD_CLASS and CLASS_DUMP record.
That is 24 bytes per record: 431 MB of the 437 MB that stripping a
1.4 GB heap dump of 17961453 instances allocated.
There are only ever 8 primitive wrapper classes, so the ids found so far
fit in a LongArray that is cheaper to scan than to hash. What stripping
allocates no longer grows with the heap dump, which matters on Android,
where stripping runs inside the app whose heap was just dumped.
Output is byte for byte identical on the Android heap dumps in our test
resources and on heap dumps taken from a JVM with both identifier sizes.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 8e1f3bb commit 70bf737
2 files changed
Lines changed: 33 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| |||
Lines changed: 32 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
171 | 171 | | |
172 | 172 | | |
173 | 173 | | |
174 | | - | |
175 | | - | |
| 174 | + | |
| 175 | + | |
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| |||
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
440 | 470 | | |
441 | 471 | | |
442 | 472 | | |
| |||
0 commit comments