My chat client has a JTextPane in which text is inserted, which can be up to a few lines per second. It usually works fine, even for a longer period of time (e.g. an hour), however sometimes it just gets incredibly slow, using a lot of CPU and memory, sometimes up to 1GB and practically freezing completely.
I added the "-Xrunhprof:heap=sites" parameter to find out what was using the memory and from what I could gather, it has something to do with text rendering, although I don't really know about this stuff, so it's more an educated guess. This is part of the result, taken while the memory usage was unusually high. I included the appropriate trace under each entry. Other heap dumps looked slightly different, but it always pointed to the same or similar classes (something with Glyph in the name). Not sure how to properly interpret this and if it is really helpful for solving this problem.
percent live alloc'ed stack class
rank self accum bytes objs bytes objs trace name
1 16.33% 16.33% 11209120 350285 99416352 3106761 319103 java.awt.geom.Rectangle2D$Float
TRACE 319103:
java.awt.geom.RectangularShape.<init>(RectangularShape.java:56)
java.awt.geom.Rectangle2D.<init>(Rectangle2D.java:511)
java.awt.geom.Rectangle2D$Float.<init>(Rectangle2D.java:111)
sun.font.StandardGlyphVector$GlyphStrike.getGlyphOutlineBounds(StandardGlyphVector.java:1790)
2 14.28% 30.61% 9799744 3958 52026864 49485 319095 float[]
TRACE 319095:
sun.font.StandardGlyphVector.getGlyphInfo(StandardGlyphVector.java:851)
sun.font.ExtendedTextSourceLabel.createCharinfo(ExtendedTextSourceLabel.java:583)
sun.font.ExtendedTextSourceLabel.getCharinfo(ExtendedTextSourceLabel.java:509)
sun.font.ExtendedTextSourceLabel.getLineBreakIndex(ExtendedTextSourceLabel.java:455)
3 8.17% 38.77% 5604560 350285 49708176 3106761 319110 sun.font.DelegatingShape
TRACE 319110:
sun.font.DelegatingShape.<init>(Delegating