<div dir="ltr"><br><br>On Tue, Feb 14, 2017 at 9:54 PM, Pavel Krivanek <<a href="mailto:pavel.krivanek@gmail.com">pavel.krivanek@gmail.com</a>> wrote:<br>> Hi,<br>><br>> It is very common to see in actively used images that the number of<br>> instances of Point is very high. Sometimes in order of hundreds of<br>> thousands. There is several reasons for that:<br>><br>> Pharo every few milliseconds checks for the new display size. That check<br>> generates two instances of Point that are not garbage collected in<br>> reasonably short time. So if you periodically check the result of "Point<br>> allInstances size", you will see that it is quickly growing.<br>> On the other hand. That Point instances are not referenced by anyone so as<br>> soon as you do Smalltalk garbageCollect, the amount of Points in reduced.<br>> And they are correctly garbage collected by the VM after some time which is<br>> often longer than one minute. So no action needed.<br><br>Even though these get cleared out, its still extra work for the GC.  Presumably most of the time the display size is identical to the last one, so I wonder if the existing screen size might be passed to the primitive to test and avoid creating a new new point if its the same.  Off the top of my head, something like this (untested)...  <br><br><div>  MorphicUIManager >> checkForNewDisplaySize</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>Display hasScreenSizeChanged ifFalse: [^ Display].<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>DisplayScreen startUp.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>World restoreMorphicDisplay.</div><div><br></div><div><div>  DisplayScreen >> hasScreenSizeChanged</div><div>      ^self class isActualScreenSizeX: width Y: height.</div></div><div><br></div>  DisplayScreen class >> isActualScreenSizeX: width Y: height<br>      <primitive: 106><div><br></div><div><div>  InterpreterPrimitives >> primitiveScreenSize "primitive 106"</div><div>        "no arguments(original) ==> DisplayScreen_class>>actualScreenSize ; returning new Point from ioScreenSIze "</div><div>        "two arguments ==> DisplayScreen_class>>isActualyScreenSizeX;Y: ; returning Boolean of whether X,Y match ioScreenSize" </div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>| pointWord x y|<br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>pointWord := self ioScreenSize.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>x := pointWord >> 16 bitAnd: 65535.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>y := pointWord bitAnd: 65535.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>argumentCount = 2 ifTrue: [</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">            </span>((x = (self stackValue: 1)) and: [y = (self stackTop)]) </div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                      </span>ifTrue: [self pop: 3 thenPush: objectMemory trueObject] </div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                      </span>ifFalse: [self pop: 3 thenPush: objectMemory trueObject].</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">              </span>].</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>self pop: 1 thenPush: (self makePointwithxValue: x    yValue: y)</div></div><div><br></div><div><snipped other sources of Points></div><div>cheers -ben<br></div><div><br></div></div>