< prev index next >

test/gc/stress/gclocker/TestGCLocker.java

Print this page
rev 12806 : 8177968: Add GC stress test TestGCLocker (01)


 145             int toRemove = cache.size() / 5;
 146             for (int i = 0; i < toRemove; i++) {
 147                 cache.remove();
 148             }
 149         }
 150         cache.add(new Filler());
 151     }
 152 
 153     public MemoryUser(String mxBeanName) {
 154         watcher = new MemoryWatcher(mxBeanName);
 155     }
 156 
 157     @Override
 158     public void run() {
 159         for (int i = 0; i < 200; i++) {
 160             load();
 161         }
 162 
 163         while (!shouldExit()) {
 164             load();
 165             ThreadUtils.sleep(100);
 166         }
 167     }
 168 }
 169 
 170 class GCLockerStresser extends Exitable implements Runnable {
 171     static native void fillWithRandomValues(byte[] array);
 172 
 173     @Override
 174     public void run() {
 175         byte[] array = new byte[1024 * 1024];
 176         while (!shouldExit()) {
 177             fillWithRandomValues(array);
 178             ThreadUtils.sleep(10);
 179         }
 180     }
 181 }
 182 
 183 public class TestGCLocker {
 184     private static Exitable startGCLockerStresser(String name) {
 185         GCLockerStresser task = new GCLockerStresser();
 186 
 187         Thread thread = new Thread(task);
 188         thread.setName(name);
 189         thread.setPriority(Thread.MIN_PRIORITY);
 190         thread.start();
 191 
 192         return task;
 193     }
 194 
 195     private static Exitable startMemoryUser(String mxBeanName) {
 196         MemoryUser task = new MemoryUser(mxBeanName);
 197 
 198         Thread thread = new Thread(task);




 145             int toRemove = cache.size() / 5;
 146             for (int i = 0; i < toRemove; i++) {
 147                 cache.remove();
 148             }
 149         }
 150         cache.add(new Filler());
 151     }
 152 
 153     public MemoryUser(String mxBeanName) {
 154         watcher = new MemoryWatcher(mxBeanName);
 155     }
 156 
 157     @Override
 158     public void run() {
 159         for (int i = 0; i < 200; i++) {
 160             load();
 161         }
 162 
 163         while (!shouldExit()) {
 164             load();

 165         }
 166     }
 167 }
 168 
 169 class GCLockerStresser extends Exitable implements Runnable {
 170     static native void fillWithRandomValues(byte[] array);
 171 
 172     @Override
 173     public void run() {
 174         byte[] array = new byte[1024 * 1024];
 175         while (!shouldExit()) {
 176             fillWithRandomValues(array);

 177         }
 178     }
 179 }
 180 
 181 public class TestGCLocker {
 182     private static Exitable startGCLockerStresser(String name) {
 183         GCLockerStresser task = new GCLockerStresser();
 184 
 185         Thread thread = new Thread(task);
 186         thread.setName(name);
 187         thread.setPriority(Thread.MIN_PRIORITY);
 188         thread.start();
 189 
 190         return task;
 191     }
 192 
 193     private static Exitable startMemoryUser(String mxBeanName) {
 194         MemoryUser task = new MemoryUser(mxBeanName);
 195 
 196         Thread thread = new Thread(task);


< prev index next >