You can measure the maximum amount of stack used by a task by
adding a switch to gnatbind
, as:
$ gnatbind -u0 file
With this option, at each task termination, its stack usage is output on
stderr
.
Note that this switch is not compatible with tools like
Valgrind and DrMemory; they will report errors.
It is not always convenient to output the stack usage when the program
is still running. Hence, you can delay this output until the
termination of the number of tasks specified as the argument of the
-u
switch. For example:
$ gnatbind -u100 file
buffers the stack usage information of the first 100 tasks to terminate and outputs it when the program terminates. Results are displayed in four columns:
Index | Task Name | Stack Size | Stack Usage
where:
By default, gnatbind
does not process the environment task stack,
the stack that contains the main unit. To enable processing of the
environment task stack, set the environment variable GNAT_STACK_LIMIT
to the maximum size of the environment task stack. This amount is
given in kilobytes. For example:
$ set GNAT_STACK_LIMIT 1600
would specify to the analyzer that the environment task stack has a limit of 1.6 megabytes. Any stack usage beyond this will be ignored by the analysis.
This is not suppored by the LLVM back end.
The package GNAT.Task_Stack_Usage
provides facilities to get
stack-usage reports at run time. See its body for the details.