This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 242917 - Every node change calls potentially expensive NbClipboard.getContents()
Summary: Every node change calls potentially expensive NbClipboard.getContents()
Status: RESOLVED DUPLICATE of bug 233513
Alias: None
Product: platform
Classification: Unclassified
Component: Explorer (show other bugs)
Version: 7.4
Hardware: PC Mac OS X
: P3 normal with 1 vote (vote)
Assignee: Jan Peska
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-14 22:56 UTC by ebakke
Modified: 2014-03-21 08:02 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
.npss file attached from NetBeans (263.62 KB, application/x-npss)
2014-03-14 23:09 UTC, ebakke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ebakke 2014-03-14 22:56:30 UTC
Changing the active Node in my platform application becomes very sluggish if the system clipboard happens to contain a large image (e.g. due to having a screenshot on the clipboard). If the clipboard contents is sufficiently large (e.g. a 3000x3000px image copied from Photoshop), I get the following stack trace whenever I select a new node (e.g. in the "Projects" or "Files" tab, with nothing else open):

java.lang.OutOfMemoryError: Java heap space
at sun.lwawt.macosx.CClipboard.getClipboardData(Native Method)
at sun.awt.datatransfer.ClipboardTransferable.fetchOneFlavor(ClipboardTransferable.java:117)
at sun.awt.datatransfer.ClipboardTransferable.<init>(ClipboardTransferable.java:97)
at sun.awt.datatransfer.SunClipboard.getContents(SunClipboard.java:147)
at org.netbeans.NbClipboard.getContents(NbClipboard.java:227)
at org.netbeans.modules.openide.explorer.ExplorerActionsImpl$ActionStateUpdater.updateTrans(ExplorerActionsImpl.java:818)
at org.netbeans.modules.openide.explorer.ExplorerActionsImpl$ActionStateUpdater.run(ExplorerActionsImpl.java:797)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1432)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2042)

The problem seems to be that ExplorerActionsImpl.ActionStateUpdater.updateTrans() calls NbClipboard.getContents(), which is potentially expensive depending on the contents of the clipboard on every single node update.

I'm running MacOS X Mavericks--not sure if this bug applies to Windows as well. I can't yet reproduce the OutOfMemoryError from the IDE--presumably it has a higher heap size by default.
Comment 1 ebakke 2014-03-14 23:09:47 UTC
Created attachment 146035 [details]
.npss file attached from NetBeans

.npss file
Comment 2 ebakke 2014-03-14 23:14:58 UTC
OK, I'm definitively able to reproduce the sluggishness in the regular NetBeans IDE now, not just from my platform application. With a 4000x4000px image copied from Photoshop to the clipboard, moving up and down the nodes in the "Projects" tab with the keyboard becomes sluggish. Attaching an IDE profiling snapshot, taken while moving quickly between nodes in the projects tab. Look at the "Hot Spots" to find ActionStateUpdater.updateTrans() consume 36 seconds (due to calls to NbClipboard.getContents).
Comment 3 ebakke 2014-03-20 17:33:37 UTC
Hmm, it gets worse. Applications like Excel expose text on the clipboard not only as text, but as a bitmap image as well, and NbClipboard.getContents appears to load the data in the image as well. Sometimes these images can get quite large, slowing down node selection in NetBeans (and causing OutOfMemoryErrors in my platform application). So this problem is more generally applicable than just for people who happen to be using Photoshop.
Comment 4 Ondrej Vrabec 2014-03-21 08:02:13 UTC

*** This bug has been marked as a duplicate of bug 233513 ***