On Thu, Dec 24, 2009 at 12:09 PM, St�phane Ducasse <stephane.ducasse@inria.fr> wrote:


> Suppose you evaluate this steps:
>
> Smalltalk at: #MDFaultDict put: Dictionary new.
> ImageSegment discoverActiveClasses
>
> .... do something here, browse, whatever ....
>
> ImageSegment activeClasses
>
> Here, you can change activeClasses to use recoverFromMDFaultWithTrace instead of recoverFromMDFault
> and with this you can see who used that class. It is stored in Smalltalk at: #MDFaultDict

Ok good to know that it is working. At some point doing that would just crash.

> Ok...at least that is what I understood, but as this is not working, I am not sure.

This is correct.

> What I suggest:
> � � � �- create a new category in the class and move all the methods that could be removed. Tag them as deprecated.

do not deprecated them since this is working. :)

> � � � �- in imageSegments just clean :)

What is the link with imageSegment?


Sorry I am lazy, I will copy paste a piece of a .tex


\section{Discovering used and unused classes}
There is some work that it is quite related to ImageSegment and it is used to discover used and unused classes.

There is a possibility to force a MethodDictionary fault with the message {\em ClassDescription>>induceMDFault}. This method copies the {\em methodDict} in the {\em organization} slot. Actually, it creates an Array with the {\em methodDict} and the {\em organization} and set it in the {\em organization} slot. Finally, it sets a {\em nil} to the {\em methodDict} instance variable. After this is done, when that class is used and the {\em methodDict} is asked\,---\,it is very important to acces the {\em methodDict} using the getter\,---\, it checks whether it is nil or not. If it is nil, it will search for that {\em methodDict} in the Array of the {\em organizaction} and it will then copy it to the {\em methodDict} instance variable.

Taking that explanation in mind, we can follow this three steps:

\begin{enumerate}
\item Send the message {\em ImageSegment>>discoverActiveClasses} which forces a MethodDictionary fault in all classes. Yes! It sends the message {\em induceMDFault} to all classes except classes like Array Object Class Message MethodDictionary. After this, all classes but those ones, will have the {\em methodDict} with {\em nil}.
\item Do a few things, use the system for a while. Maybe even save and resume the image.
\item Now, it is easy. All classes that still have a nil in the {\em mehodDict} is because they were not used, and those who have something different from {\em nil} is because they were. With the message {\em ImageSegment>>activeClasses} you can restore all remaining MethodDictionary faults and return the active classes. And with the message {\em ImageSegment>>swapOutInactiveClasses}� you can make up segments by grouping unused classes by system category and write them to disk.

A very important thing is that if you send the message {\em discoverActiveClasses}� you must then have to send the message {\em activeClasses} or {\em swapOutInactiveClasses}� because otherwise you will have a lot of classes with the {\em methodDict} in {\em nil}.

\end{enumerate}


is it clear ?

>
>
> Ok. Perfect.
>
> Cheers
>
> Mariano
>
> Stef
> _______________________________________________
> Pharo-project mailing list
> Pharo-project@lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project@lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project