Quantcast

Re: [Pharo-dev] Points, Free type fonts cache and memory leaks

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Pharo-dev] Points, Free type fonts cache and memory leaks

Ben Coman
 


On Tue, Feb 14, 2017 at 9:54 PM, Pavel Krivanek <[hidden email]> wrote:

> Hi,
>
> It is very common to see in actively used images that the number of
> instances of Point is very high. Sometimes in order of hundreds of
> thousands. There is several reasons for that:
>
> Pharo every few milliseconds checks for the new display size. That check
> generates two instances of Point that are not garbage collected in
> reasonably short time. So if you periodically check the result of "Point
> allInstances size", you will see that it is quickly growing.
> On the other hand. That Point instances are not referenced by anyone so as
> soon as you do Smalltalk garbageCollect, the amount of Points in reduced.
> And they are correctly garbage collected by the VM after some time which is
> often longer than one minute. So no action needed.

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)...  

  MorphicUIManager >> checkForNewDisplaySize
Display hasScreenSizeChanged ifFalse: [^ Display].
DisplayScreen startUp.
World restoreMorphicDisplay.

  DisplayScreen >> hasScreenSizeChanged
      ^self class isActualScreenSizeX: width Y: height.

  DisplayScreen class >> isActualScreenSizeX: width Y: height
      <primitive: 106>

  InterpreterPrimitives >> primitiveScreenSize "primitive 106"
        "no arguments(original) ==> DisplayScreen_class>>actualScreenSize ; returning new Point from ioScreenSIze "
        "two arguments ==> DisplayScreen_class>>isActualyScreenSizeX;Y: ; returning Boolean of whether X,Y match ioScreenSize" 
| pointWord x y|
pointWord := self ioScreenSize.
x := pointWord >> 16 bitAnd: 65535.
y := pointWord bitAnd: 65535.
argumentCount = 2 ifTrue: [
((x = (self stackValue: 1)) and: [y = (self stackTop)]) 
ifTrue: [self pop: 3 thenPush: objectMemory trueObject] 
ifFalse: [self pop: 3 thenPush: objectMemory trueObject].
].
self pop: 1 thenPush: (self makePointwithxValue: x    yValue: y)

<snipped other sources of Points>
cheers -ben

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Pharo-dev] Points, Free type fonts cache and memory leaks

Denis Kudriashov
 

2017-02-14 16:12 GMT+01:00 Ben Coman <[hidden email]>:
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)...  

  MorphicUIManager >> checkForNewDisplaySize
Display hasScreenSizeChanged ifFalse: [^ Display].
DisplayScreen startUp.
World restoreMorphicDisplay.

I hope with SDL we will be able remove such loops. There is OSWindowResizeEvent which can be handled immediately when it's happened
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Pharo-dev] Points, Free type fonts cache and memory leaks

timrowledge
 

> On 14-02-2017, at 7:20 AM, Denis Kudriashov <[hidden email]> wrote:
>
>
> 2017-02-14 16:12 GMT+01:00 Ben Coman <[hidden email]>:
> 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)...  
>
>   MorphicUIManager >> checkForNewDisplaySize
> Display hasScreenSizeChanged ifFalse: [^ Display].
> DisplayScreen startUp.
> World restoreMorphicDisplay.
>
> I hope with SDL we will be able remove such loops. There is OSWindowResizeEvent which can be handled immediately when it's happened

Doesn’t need to have anything to do with SDL; any UI framework ought to be able to provide a suitable event, even if it has to be faked. X11 appears to use the ConfigureNotify event for example. It does require some care to get this stuff right, by the way; with Squeak wanting to be able to control the screen size a fullscreen status (including remembering the prior size and so on) as well as the UI wanting to control it… things can easily get into nasty loops. DAMHIKT.

In a Squeak image this display size test is done roughly 50/sec, which is not exactly going to cause a flood of ‘waste’ Points. I suspect there are much more worthy targets.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Useful random insult:- Several nuts over fruitcake minimum.


Loading...