Mega Code Archive

 
Categories / Java Tutorial / Class Definition
 

Memory Leak Demo

class List {   MemoryLeak mem;   List next; } class MemoryLeak {   static List top;   char[] memory = new char[100000];   public static void main(String[] args) {     for (int i = 0; i < 100000; i++) {       List temp = new List();       temp.mem = new MemoryLeak();       temp.next = top;       top = temp;     }   } }