Advertisement
Guest User

7vies

a guest
May 18th, 2009
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. public class GcTest {
  2.     public static void main(String[] args) {
  3.     int i;
  4.     CacheTest c = new CacheTest();
  5.     for (i=0; i<100; i++) {
  6.         int a[] = new int[100000];
  7.     }
  8.     }
  9. }
  10.  
  11. class CacheTest {
  12.     CacheTest() {
  13.         new GcHelper(); // "hook"
  14.     }
  15.     static void gcEvent() {
  16.         System.out.println("Cache.gcEvent");
  17.         new GcHelper(); // restoring "hook"
  18.     }
  19. }
  20.  
  21. class GcHelper extends Object {
  22.     protected void finalize() throws Throwable {
  23.         try {
  24.             CacheTest.gcEvent();
  25.         }
  26.         finally {
  27.             super.finalize();
  28.         }
  29.     }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement