Dear all, I run recently netbeans profiler on my swing application (Aspro2: http://www.jmmc.fr/aspro) under linux x64 platform and I figured out that a lot of char[] instances are coming from String + operator called by sun.awt.X11 code.
I looked at PlatformLogger source code but found not way to disable it completely: maybe an empty logger implementation could be interesting to be used during profiling or normal use (not debugging). Apparently JDK8 provides some patchs to avoid String creation when the logger is disabled (level). However, I looked also to the sun.awt code (jdk7u repository) to see the origin of the string allocations: XDecoratedPeer: public void handleFocusEvent(XEvent xev) { ... * focusLog.finer("Received focus event on shell: " + xfe); * } public boolean requestWindowFocus(long time, boolean timeProvided) { ... * focusLog.finest("Real native focused window: " + realNativeFocusedWindow + "\nKFM's focused window: " + focusedWindow); *... * focusLog.fine("Requesting focus to " + (this == toFocus ? "this window" : toFocus)); *... } XBaseWindow: public void xSetBounds(int x, int y, int width, int height) { ... * insLog.fine("Setting bounds on " + this + " to (" + x + ", " + y + "), " + width + "x" + height); *} XNetProtocol: boolean doStateProtocol() { ... * stateLog.finer("doStateProtocol() returns " + res); *} XSystemTrayPeer: XSystemTrayPeer(SystemTray target) { ... * log.fine(" check if system tray is available. selection owner: " + selection_owner); *} void addTrayIcon(XTrayIconPeer tiPeer) throws AWTException { ... * log.fine(" send SYSTEM_TRAY_REQUEST_DOCK message to owner: " + selection_owner); *} XFramePeer: public void handlePropertyNotify(XEvent xev) { ... stateLog.finer("State is the same: " + state); } However I only give here few cases but certainly others are still present in the source code; maybe findbugs or netbeans warnings could help you finding all of them. I advocate the amount of waste (GC) is not very important but String conversion are also calling several toString() methods that can be costly (event, Frame, window ...) Finally, I ran few grep commands on the sun.awt.X11 code (jdk7u) and you can look at them to see all string + operations related to log statements. PS: I may help fixing the source code but I have no idea how to collaborate (provide a patch ?) Regards, Laurent Bourgès
X11_log_str_concat.log
Description: Binary data
X11_log_str_concat_noIsLoggable.log
Description: Binary data