|
In Smalltalk MT 4.0 we introduced a new way to track allocations in a
specific piece of code using the StDbgHandler class. In Smalltalk 4.2, we have
extended this class to track allocations in blocks or between a start and an end
point.
If you haven't used this class, now would be a good time to start. First, you
must copy the debug version of the run time DLL from the Smalltalk MT
subdirectory 'support' subdirectory 'debug' to where you will run your image.
Next you must file in 'Debug trace handler.sp' from the Smalltalk MT
subdirectory 'source' subdirectory 'debug trace'.
In the Class Hierarchy Browser, locate the 'StDbgHandler' class. If you right
click on this class, you will see menus at the bottom under 'Alloc Trace' to
start and stop allocation tracing.
So for example I turned 'Alloc Trace' on and executed
10 timesRepeat: ['abc','def','ghi']
Then turned 'Alloc Trace' off. I see 159 allocations some of which are from
turning the allocation handler on and off. If you want a more accurate measure
of allocations, use
StDbgHandler resetAllocTrace.
StDbgHandler recordAllocationsFor: [
10 timesRepeat: ['abc','def','ghi']
].
StDbgHandler inspectAllocTrace
Or:
StDbgHandler startTraceAlloc.
10 timesRepeat: ['abc','def','ghi'].
StDbgHandler endTraceAlloc
Both of these show 20 allocations and using the trace window, you can drill
down to where the allocation actually happened

|