I'm finding that any time I set text on a JLabel with HTML, an 8KB buffer gets allocated, even though my label text may be very short. Digging in a bit, it looks like the culprit lies in DefaultStyledDocument:
public static final int BUFFER_SIZE_DEFAULT = 4096;
It looks like every time the text is changed, a property change listener fires, and a new HTMLDocument is allocated, with a GapContent of that default buffer size. 4k characters in UTF-16 gives me 8K worth of memory for a tiny little label.
As far as I can tell, I can't change change that value before the doc gets allocated. I thought reflection might come in handy, per Change private static final field using Java reflection, but it looks like I'm out of luck according to the second answer. I've thought about resizing the gap buffer after the fact, but that seems pretty tricky.
Anybody come across this before? I expect I'm going to have to get very hackity to even stand a chance...
Thanks!