Advertisement
Guest User

fixed bug using too many Smalltalk garbageCollect

a guest
Sep 5th, 2011
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. i :=1.
  2. myRectArray :=Array new:10.
  3. rnd := [(-500 to: 500) atRandom].
  4.  
  5.     myGrid := PasteUpMorph new openInWorld.
  6.     myGrid height: 1100;width:1100.
  7.     aRec := myGrid center.
  8.     myRectArray at: i put: RectangleMorph new.
  9.     1to: i do: [:count|  myGrid addMorph: (myRectArray at: count)].
  10.  
  11.  
  12. gC :=1.
  13.     [Transcript show: (Time millisecondsToRun:[
  14.         1 to:1000 do: [:j|
  15.            
  16.             1 to: 1000 do: [:k|
  17.             1to: i do: [:l|
  18.                 (myRectArray at: l) center: aRec +(rnd value@rnd value).
  19.                 gC := gC + 1.
  20.                 ((gC \\1000) = 0) ifTrue: [Smalltalk garbageCollect.].
  21.                 ].
  22.             ]]]);cr] fork.
  23.  
  24. "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
  25. myGrid delete.
  26. Smalltalk garbageCollect.
  27. i :=9.
  28.     myGrid := PasteUpMorph new openInWorld.
  29.     myGrid height: 1100;width:1100.
  30.     aRec := myGrid center.
  31.     myRectArray at: i put: RectangleMorph new.
  32.     1to: i do: [:count|  myGrid addMorph: (myRectArray at: count)].
  33.  
  34. gC :=1.
  35.     [Transcript show: (Time millisecondsToRun:[
  36.         1 to:1000 do: [:j|
  37.            
  38.             1 to: 1000 do: [:k|
  39.             1to: i do: [:l|
  40.                 (myRectArray at: l) center: aRec +(rnd value@rnd value).
  41.                 gC := gC + 1.
  42.                 ((gC \\1000) = 0) ifTrue: [Smalltalk garbageCollect.].
  43.                 ].
  44.             ]]]);cr] fork.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement