Information Technology Reference
In-Depth Information
In a real project, this kind of information can give you useful debugging hints, but even more detail is available.
If you select the detail triangle next to an allocation event, you see the display shown in Figure 16.15. The crit-
ical column here is RefCt, which is the object's reference count.
The object view in the Allocations instrument is the only way to get a reliable reference count. Conveniently,
you can view the counts of multiple objects simultaneously. This can be a lifesaver on projects with memory is-
sues, because it gives you an X-ray of the app's memory events. You can interact with the app while it's running
and monitor an object to check whether it's being allocated and released correctly.
CAUTION
Don't forget that Cocoa may not release objects immediately after they receive a release or autorelease mes-
sage. Depending on the context, some other object may be retaining your target object. Or it may simply take Co-
coa a short while to run the release or autorelease code. However Cocoa handles an object, you can monitor it
with Instruments.
FIGURE 16.15
Looking at a single object allocation to view the reference count
Search WWH ::




Custom Search