67
67
this.appContextProtection = appContextProtection;
71
* Protect against the memory leak caused when the first call to
72
* <code>sun.net.www.http.HttpClient</code> is triggered by a web
73
* application. This first call will start a KeepAlive thread with the
74
* thread's context class loader configured to be the web application class
75
* loader. Defaults to <code>true</code>.
77
private boolean keepAliveProtection = true;
78
public boolean isKeepAliveProtection() { return keepAliveProtection; }
79
public void setKeepAliveProtection(boolean keepAliveProtection) {
80
this.keepAliveProtection = keepAliveProtection;
71
84
* Protect against resources being read for JAR files and, as a side-effect,
72
85
* the JAR file becoming locked. Note this disables caching for all
142
* Several components end up calling:
143
* sun.misc.GC.requestLatency(long)
145
* Those libraries / components known to trigger memory leaks due to
146
* eventual calls to requestLatency(long) are:
147
* - javax.management.remote.rmi.RMIConnectorServer.start()
149
if (gcDaemonProtection) {
151
Class<?> clazz = Class.forName("sun.misc.GC");
152
Method method = clazz.getDeclaredMethod("requestLatency",
153
new Class[] {long.class});
154
method.invoke(null, Long.valueOf(3600000));
155
} catch (ClassNotFoundException e) {
156
if (System.getProperty("java.vendor").startsWith("Sun")) {
157
log.error(sm.getString(
158
"jreLeakListener.gcDaemonFail"), e);
160
log.debug(sm.getString(
161
"jreLeakListener.gcDaemonFail"), e);
163
} catch (SecurityException e) {
164
log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
165
} catch (NoSuchMethodException e) {
166
log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
167
} catch (IllegalArgumentException e) {
168
log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
169
} catch (IllegalAccessException e) {
170
log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
171
} catch (InvocationTargetException e) {
172
log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
177
* When a servlet opens a connection using a URL it will use
178
* sun.net.www.http.HttpClient which keeps a static reference to a
179
* keep-alive cache which is loaded using the web application class
182
if (keepAliveProtection) {
184
Class.forName("sun.net.www.http.HttpClient");
185
} catch (ClassNotFoundException e) {
186
if (System.getProperty("java.vendor").startsWith("Sun")) {
187
log.error(sm.getString(
188
"jreLeakListener.keepAliveFail"), e);
190
log.debug(sm.getString(
191
"jreLeakListener.keepAliveFail"), e);
129
197
* Several components end up opening JarURLConnections without first
130
198
* disabling caching. This effectively locks the file. Whilst more
131
199
* noticeable and harder to ignore on Windows, it affects all
167
235
log.error(sm.getString("jreLeakListener.xmlParseFail"), e);
172
* Several components end up calling:
173
* sun.misc.GC.requestLatency(long)
175
* Those libraries / components known to trigger memory leaks due to
176
* eventual calls to requestLatency(long) are:
177
* - javax.management.remote.rmi.RMIConnectorServer.start()
179
if (gcDaemonProtection) {
181
Class<?> clazz = Class.forName("sun.misc.GC");
182
Method method = clazz.getDeclaredMethod("requestLatency",
183
new Class[] {long.class});
184
method.invoke(null, Long.valueOf(3600000));
185
} catch (ClassNotFoundException e) {
186
if (System.getProperty("java.vendor").startsWith("Sun")) {
187
log.error(sm.getString(
188
"jreLeakListener.gcDaemonFail"), e);
190
log.debug(sm.getString(
191
"jreLeakListener.gcDaemonFail"), e);
193
} catch (SecurityException e) {
194
log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
195
} catch (NoSuchMethodException e) {
196
log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
197
} catch (IllegalArgumentException e) {
198
log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
199
} catch (IllegalAccessException e) {
200
log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);
201
} catch (InvocationTargetException e) {
202
log.error(sm.getString("jreLeakListener.gcDaemonFail"), e);