Last active
December 17, 2015 15:28
-
-
Save philz/5631456 to your computer and use it in GitHub Desktop.
Using sqlite3 to analyze two jmap heap histograms. Using SQL is a powerful way to query and compare two data sets, like the output of jmap.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jmap -histo:live $pid > old.jmap | |
sleep $((60*60)) | |
jmap -histo:live $pid > new.jmap | |
cat old.jmap | awk 'BEGIN { OFS="|" } /:/ { print $2, $3, $4 }' > old.txt | |
cat new.jmap | awk 'BEGIN { OFS="|" } /:/ { print $2, $3, $4 }' > new.txt | |
sqlite3 | |
sqlite> create table new(count, bytes, class); | |
sqlite> create table old(count, bytes, class); | |
sqlite> .import new.txt "new"; | |
sqlite> .import old.txt "old"; | |
sqlite> select n.class, n.count - o.count, n.bytes - o.bytes as deltabytes from old o, new n where o.class=n.class order by deltabytes desc limit 50; | |
# Example output: | |
[I|19932|82352424 | |
[C|24075|23852240 | |
java.lang.String|711673|22773536 | |
[Ljava.lang.Object;|9974|3466336 | |
[Ljava.lang.String;|1415|2754192 | |
[[B|41|2721344 | |
[[I|29151|1402064 | |
net.sf.ehcache.Element|18343|1173952 | |
org.hibernate.cache.spi.CacheKey|36384|1164288 | |
java.lang.Long|46795|1123080 | |
java.util.LinkedHashMap$Entry|22708|908320 | |
org.hibernate.cache.ehcache.internal.strategy.AbstractReadWriteEhcacheAccessStrategy$Lock|12409|694904 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment