Skip to content

Commit

Permalink
Document -trackOwnership
Browse files Browse the repository at this point in the history
  • Loading branch information
rfm committed Jan 18, 2025
1 parent 30104e7 commit d746ad5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Documentation/manual/ExceptionHandling.texi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d746ad5

Please sign in to comment.