public void setAppContextProtection(boolean appContextProtection) {
this.appContextProtection = appContextProtection;
}
-
+
+ /**
+ * Protect against the memory leak caused when the first call to
+ * <code>java.awt.Toolkit.getDefaultToolkit()</code> is triggered
+ * by a web application. Defaults to <code>false</code> because a new
+ * Thread is launched.
+ */
+ private boolean awtThreadProtection = false;
+ public boolean isAWTThreadProtection() { return awtThreadProtection; }
+ public void setAWTThreadProtection(boolean awtThreadProtection) {
+ this.awtThreadProtection = awtThreadProtection;
+ }
+
/**
* Protect against the memory leak caused when the first call to
* <code>sun.misc.GC.requestLatency(long)</code> is triggered by a web
if (appContextProtection) {
ImageIO.getCacheDirectory();
}
-
+
+ // Trigger the creation of the AWT (AWT-Windows, AWT-XAWT,
+ // etc.) thread
+ if (awtThreadProtection) {
+ java.awt.Toolkit.getDefaultToolkit();
+ }
+
/*
* Several components end up calling:
* sun.misc.GC.requestLatency(long)
is <code>true</code>.</p>
</attribute>
+ <attribute name="AWTThreadProtection" required="false">
+ <p>Enables protection so that calls to
+ <code>java.awt.Toolkit.getDefaultToolkit()</code> triggered by a web
+ application do not result in a memory leak.
+ Defaults to <code>false</code> because an AWT thread is launched.</p>
+ </attribute>
+
<attribute name="driverManagerProtection" required="false">
<p>The first use of <code>java.sql.DriverManager</code> will trigger the
loading of JDBNC Driver in the the current class loader. The web