mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 08:21:25 +00:00
Document -trackOwnership
This commit is contained in:
parent
30104e74f5
commit
d746ad53d7
1 changed files with 18 additions and 0 deletions
|
@ -451,6 +451,24 @@ of statistics collection is only incurred when it is active. To access the
|
|||
statistics, use the set of @code{GSDebugAllocation...()} functions defined in
|
||||
@code{NSDebug.h}.
|
||||
|
||||
In addition to basic statistics (but at higher performance cose), the
|
||||
@code{GSDebugAllocation...()} functions provide detailed records of when and
|
||||
where objects are allocated/deallocated. This can be useful when debugging
|
||||
for memory leaks.
|
||||
|
||||
Finally, for pinpoint accuracy, the -trackOwnership method can be called on
|
||||
an individual object to turn on tracking of the lifetime of that object. In
|
||||
this case a stack trace is printed logging every ownership event (retain,
|
||||
release, or dealloc) and a log is printed at process exit if the object
|
||||
has not been deallocated. The same method may be called on a class to
|
||||
track every object of that class. This method is declared in
|
||||
@code{NSObject+GNUstepBase.h}. Tracking the life of an individual object is
|
||||
particularly useful if a leak checker (eg when your program was built using
|
||||
@code{(make asan=yes)} or run under valgrind) has reported a leak and the
|
||||
cause of the leak is hard to find: the leak checker will have told you the
|
||||
stack trace where the leaked memory was allocated, so you can change your
|
||||
code to start tracking immediately after that and see exacly what happened
|
||||
to the object ownership after its creation.
|
||||
|
||||
@section Assertions
|
||||
@cindex assertions
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue