Skip to content
Browse files
[JENKINS-15156] Class loading errors can result from OOME if you are …
…not careful.
  • Loading branch information
jglick committed Feb 7, 2013
1 parent fad1df3 commit 74e6409a06531144316f2e36bdc0b069de52b94d
Showing with 1 addition and 0 deletions.
  1. +1 −0 test/src/main/java/org/jvnet/hudson/test/
@@ -134,6 +134,7 @@ public static void assertHeapUsage(Object o, int max) throws Exception {
* @param reference object used to verify garbage collection.
public static void assertGC(WeakReference<?> reference) {
assertTrue(true); reference.get(); // preload any needed classes!
Set<Object[]> objects = new HashSet<Object[]>();
while (true) {
try {

1 comment on commit 74e6409


This comment has been minimized.

Copy link
Member Author

@jglick jglick commented on 74e6409 Feb 7, 2013

@johnou was curious about this commit, so for the record:

If you do not do this, it is possible that a concurrent class load will get an OutOfMemoryError (collateral damage), and Java will not try reloading it. So you get NoClassDefFoundErrors on that class henceforth, which can send everything south. I saw this on ComputerSet when I tried to run the test. The original assertGC is smarter because it actually tries to call System.gc and check if the WeakReference is collected before “escalating” the memory pressure to the point of an OutOfMemoryError.

Please sign in to comment.