| None. |
|
Writes the runtime's string and object counters to the debug log. One call produces exactly three lines: Active strings :N Active objects :N Unreleased objs:N "Active objects" is how many custom Type objects currently exist, "Active strings" how many string values the runtime is holding, and "Unreleased objs" how many objects the runtime still has an internal reference to. They are leak-hunting numbers, not performance numbers. The way to use it is as a before-and-after pair. Call RuntimeStats when your game reaches the menu, play a level, come back to the menu and call it again: if the object count has grown, something in the level is not being Deleted. Sprinkling a call at the top and bottom of a level-load routine finds the same problem more precisely. Because the counts include every object of every Type, the interesting thing is the change between two calls rather than any single number. The important gotcha is where the text goes. RuntimeStats writes through the same channel as DebugLog, which is the debugger's Debug Log panel - so you only see it when you run the program from the IDE with debugging enabled. Run without a debugger attached and the command still executes, costs almost nothing and produces no visible output at all. It never prints to the program window, so do not expect it to behave like Print. See also: DebugLog, Delete, Handle, Object, Type. |
; RuntimeStats Example
; --------------------
Type Bullet
Field x#
Field y#
End Type
; Fill the world with objects and strings so the counters have
; something interesting to report
For i=1 To 200
b.Bullet=New Bullet
b\x=i
tag$="bullet "+i
Next
Print "RuntimeStats writes three lines to the debug log:"
Print " Active strings :N"
Print " Active objects :N"
Print " Unreleased objs:N"
Print ""
; The line this example is about - one snapshot with the bullets alive
RuntimeStats
; Clear the bullets and take a second snapshot, so the two entries in
; the log show the object count dropping
For b.Bullet=Each Bullet
Delete b
Next
RuntimeStats
Print "Two snapshots have been taken - one with 200 bullets alive and"
Print "one after deleting them."
Print ""
Print "The counts go to the same place as DebugLog, which means the"
Print "Debug Log panel of the IDE's debugger. Run this from the IDE"
Print "with debugging enabled to read them; with debugging off the"
Print "command still runs but there is nowhere for the text to appear."
Print ""
Print "Press any key to close the example"
WaitKey
End