Hi Russ, That is great to hear. I wanted to add that Pharo has automatic memory management and there is normally no need for doing anything manually (like nilling out instance variables let alone ugly become hacks). Your model looks pretty harmless, even with cycles there should be no problems. All this does not mean that you cannot (by accident maybe) make mistakes and keep global references to your larger model that prevents it from being garbage collected. Typically, fixing the one culprit solves all your problems. The trick is finding it ;-) Sven
On 1 Apr 2020, at 20:04, Russ Whaley <whaley.russ@gmail.com> wrote:
Okay! I made some additional changes to my app/presenter/model so that I'm doing this:
MyApp>>start | model pres | model := MyModel loadData. pres := MyPresenterWithModel newApplication: self with: model. pres openWithSpec.
I changed my code in Presenter to reference the model - and it pops right up! When I close the GUI, GC and check for errant object instances... NONE!! I can open the UI over and over and my object instances stay at zero.
So it feels like I'm on the right track.
I still need a bunch of work/learning around the App/Presenter/Model interactions... so if anyone can point me to a good tutorial on this, including changing data and UI widgets - I'd greatly appreciate it.
Thanks to all on this issue!
Russ
On Wed, Apr 1, 2020 at 12:14 PM Russ Whaley <whaley.russ@gmail.com> wrote: Tim, Thanks for the reply! When I eliminated (with your become: solution), it did not a small chunk of the objects instances off. Another 'holder' of object instances accounted for another slug. But things still were not dropping like I hoped (this is without just setting everything to strings - but doing so systematically by object to perhaps see what was holding on to things). Finally I got things down to a few objects with instances in the hundreds and thousands - instead of 50,000 and 400,000 - and I finally set everything to String new. Interestingly enough, after garbage collection, when I do String instanceCount - I get 0 (zero) instances.
All that - and thank you again - I closed all the system browsers, checked playground to delete bindings, I did a bunch of garbageCollection runs, did a System>Do Image Cleanup... then did a Save As.
And... it is 8MB bigger than before I did all this cleanup. My image was 346MB and grew to 354MB AFTER the cleanup. Go figure. Maybe it will automagically GC sometime.
I'm looking into what you and Sven mentioned - the pointersTo - I'm trying to figure out how to use it.
A couple of basic questions... ⢠I thought tempVariables, inside a method were automatically destroyed when the method terminated? ⢠If I pass an object (either a parm or tempVariable) that resides in that message to another message, since I'm passing the actual object - I curious how it ever gets GC'd. ⢠All my ObjectTest classes create their own data to work with - I have the creation in centralized messages, but they return 'fresh' data for each test. Whatever the answer is in the first 2 bullet points, this could be a contributor to the volume. I'm running some tests of the GUI after clearing out all the Object instances... and I'm seeing the growth as expected... it just doesn't go away when I close the GUI window. I'm not using SpApp correctly, nor am I using SpPresenter correctly (I'm forcing my model data into an SpPresenter instVar (via the SpApp start) so the presenter can use my data. This is all wrong but I'm struggling finding good examples in Spec2 of how to get these to work together.
Thanks for the info - your suggestions have been very helpful! Russ
On Wed, Apr 1, 2020 at 2:43 AM Tim Mackinnon <tim@testit.works> wrote: Hi Russ - a quick look at your stats seems to indicate that something is holding on to your model, I didnât understand the first object growing by 2, but the second increases by 1 each time, and it looks like some form of root object holding on to the others ? This of course means the GC canât reclaim the chain of objects if something is holding on to that root globally.
Assigning something in the playground will hold onto it (I believe) so you can continue to reuse and inspect it - so thatâs expected, but this looks like something in your UI?
You can break the chain manually (but itâs not a full solution), simply iterate over your root and become: String new (Save your image before doing it and see if it works to free up the cycles). Eg try something like this (havenât tried this in Pharo myself, but worked in VA, so it should work here)
MyRootModel allInstances do: [ :m | m become: String new ]
If this works and reduces your memory usage, you now need to inspect one of those MyRootModel instances and see who is referencing it, and explain why. This is Svenâs pointerTo explanation.
For roots, you sometimes can use a WeakDictionary so that when nothing is referencing them, they get gcâd if you are doing some caching or have some factory concept.
Itâs not uncommon to hit this when you get your system nearing completion , itâs the downside of not having to worry about memory referencing - ultimately you have to worry about it at the edges.
It is possible there is a Pharo bug, as over time I see large Pharo images but I was just messing around and put it down to failed experiments.
Hope this helps.
Tim
On 31 Mar 2020, at 20:47, Russ Whaley <whaley.russ@gmail.com> wrote:
 Here is some additional data - attached - I checked the number of instances on select Classes before a UI load, during the UI load and after the UI load (and again). The class instances grow as expected, but do no release. I'm doing something wrong. I'm going to try a fresh image next, however, I expect the same thing to happen, just starting over at zero.
On Tue, Mar 31, 2020 at 12:57 PM Russ Whaley <whaley.russ@gmail.com> wrote: Dario, Thanks for the reply!
When I closed my image - after running that huge query and leaving it in an inspector... my image grew to 1.3GB, lol.
When I closed the inspector, and all the class browsers, did the garbage collection, etc., it dropped back to 384MB. Still huge, and all my Class instances are still there. I'm getting ready to also drop my Playground - after I copy all the code snippets out and see if that has any impact. I'm also going to try a fresh image and see if there is the same growth pattern as here.
Perhaps I'm doing something wrong with the way I'm creating and storing my object instances - which is generally Class new, fill out some attributes, then add it to a collection or Dictionary.
All my Object tests create sample data (objects) - over and over as well.
On Tue, Mar 31, 2020 at 12:20 PM dario.trussardi65 <dario.trussardi65@gmail.com> wrote: Ciao,
My image size keeps growing and growing. I've been scouring Google and mailing lists, trying to find a solution.
i have the same problem with a Pharo 7 image.
Maybe it has nothing to do.
But after close all the class browser windows the image save return to a " valid " size.
Dario
-- Russ Whaley whaley.russ@gmail.com
-- Russ Whaley whaley.russ@gmail.com <Class instances tests.pdf>
-- Russ Whaley whaley.russ@gmail.com
-- Russ Whaley whaley.russ@gmail.com