EVALUATION
Name: agR10216 Date: 12/10/2002
The problem is reproducible on any platform.
Clipboard.getContents() fetches clipboard data in all provided
formats for which mapping to the corresponding data flavor in
the default flavor map exists.
So if there are a lot of formats in which clipboard data are to
be fetched and the data are big enough, a lot of memory is
consumed with the fetched data in different formats.
I think, it was a design decision for Clipboard.getContents()
to return a self-sufficient Transferable that is independent
of the system clipboard contents later on.
We should consider implementation possibility of a new API that
allows to fetch current system clipboard data in the one
specified data flavor, without prefetching data in several
clipboard formats.
###@###.### 2002-12-10
======================================================================
Name: agR10216 Date: 06/27/2003
This problem was fixed along with the RFE 4287795
(Would like Clipboard.isDataFlavorSupported() method).
###@###.### 2003-06-27
======================================================================

2003-06-27

WORK AROUND
Name: agR10216 Date: 12/10/2002
Comment some mappings between native clipboard formats and Java
data flavors in the file jre/lib/flavormap.properties.
For example, if you want to paste into your Java application a
large Microsoft Excel table, copied to the system clipboard, as a
text, you should commemt all lines except that contains mapping
for the 'UNICODE TEXT' format.
###@###.### 2002-12-10
======================================================================
Name: agR10216 Date: 12/10/2002
Also you can correct mappings between native clipboard formats
and Java data flavors from your Java program.
Since image data typically require a lot of memory, you can
refuse to fetch clipboard data in the image formats.
It is shown in the following code.
FlavorMap fm = SystemFlavorMap.getDefaultFlavorMap();
if (fm instanceof SystemFlavorMap) {
SystemFlavorMap sfm = (SystemFlavorMap)fm;
List ln = sfm.getNativesForFlavor(DataFlavor.imageFlavor);
DataFlavor[] flavors = new DataFlavor[0];
for (Iterator it = ln.iterator(); it.hasNext();) {
sfm.setFlavorsForNative((String)it.next(), flavors);
}
}
###@###.### 2002-12-10
======================================================================