Guest User

Untitled

a guest
Jan 29th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 0.65 KB | None | 0 0
  1. package ;
  2.  
  3. import cpp.Lib;
  4. import cpp.vm.WeakRef;
  5.  
  6. class MemoryMonster
  7. {
  8.     public var food:Array<Float>;
  9.  
  10.     public function new()
  11.     {
  12.         food = [];
  13.         for (i in 0...50000)
  14.             food.push(Math.random());
  15.     }
  16. }
  17.  
  18. /**
  19.  *
  20.  */
  21. class Main
  22. {
  23.     static function main()
  24.     {
  25.         var list =  [];
  26.  
  27.         trace("Allocating some memory monsters. Evolution will pick the strongest!");
  28.  
  29.         for (i in 0...3000)
  30.             list.push(new WeakRef(new MemoryMonster()));
  31.  
  32.         trace("Let's see who survived natural selection.");
  33.  
  34.         for (i in 0...list.length)
  35.             trace(list[i].get());
  36.     }
  37.    
  38. }
Advertisement
Add Comment
Please, Sign In to add comment