[Pharo-project] Question about MethodContext, tempNames and GC
Hi. These days, I needed to implement a loop detector for one of my projects, and I started to play a lit with thisContext. I've used it before but not as deep as now. It is AWESOME!!!! Now...I noticed (and I think this was the most awesome thing) that I can not only access to senders and their receivers and methods, but also to the arguments!!! And then I thought... mmmmmm how can I access the arguments of a sender of a sender of .... because I thought they should be garbage collected, but if I can access. Ok, there is when I discover that this information is stored in a DebuggerMethodMap and I guess this guy uses a kind of WeakArray to store them. Now, for my loop detector, I use thisContext to access senders AND I need to access the arguments of a method of a sender. For that I use the method ContextPart >> tempsAndValues The question is....isn't this method quite "fragile"? I mean, doesn't this work ONLY if a GC was not run between thisContext and that context ? I am right ? I need to know this to see if I can trust on this or not. And if I am right, maybe we can modify and add this info in a comment? Thanks Mariano
And then I thought... mmmmmm how can I access the arguments of a sender of a sender of .... because I thought they should be garbage collected, but if I can access. Ok, there is when I discover that this information is stored in a DebuggerMethodMap and I guess this guy uses a kind of WeakArray to store them.
No, arguments need to kept with the context object until the context object itself is not used anymore (e.g. not referenced from anywhere and execution completed with a return or unwind).
Now, for my loop detector, I use thisContext to access senders AND I need to access the arguments of a method of a sender.
Go to the Process Browser and click on 'start CPUWatcher'. It kind of does that. Lukas -- Lukas Renggli www.lukas-renggli.ch
participants (2)
-
Lukas Renggli -
Mariano Martinez Peck