Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GcTest {
- public static void main(String[] args) {
- int i;
- CacheTest c = new CacheTest();
- for (i=0; i<100; i++) {
- int a[] = new int[100000];
- }
- }
- }
- class CacheTest {
- CacheTest() {
- new GcHelper(); // "hook"
- }
- static void gcEvent() {
- System.out.println("Cache.gcEvent");
- new GcHelper(); // restoring "hook"
- }
- }
- class GcHelper extends Object {
- protected void finalize() throws Throwable {
- try {
- CacheTest.gcEvent();
- }
- finally {
- super.finalize();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement