Add object logging services for investigating memory leaks (#15566)

This commit is contained in:
J. Nick Koston 2020-11-09 10:54:48 -10:00 committed by GitHub
parent c0835221ad
commit 013c658239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -53,3 +53,25 @@ The `hpy` file can be viewed with any text editor. A visual representation can b
from guppy import hpy from guppy import hpy
hpy().pb() hpy().pb()
``` ```
### Service `profiler.start_log_objects`
Start logging the growth of objects in memory.
| Service data attribute | Optional | Description |
| ---------------------- | -------- | ----------- |
| `scan_interval` | yes | The the frequency between logging objects. Defaults to 30.0
Periodically log the growth of new objects in memory. This service's primary use case is finding memory leaks.
### Service `profiler.stop_log_objects`
Stop logging the growth of objects in memory.
### Service `profiler.dump_log_objects`
| Service data attribute | Optional | Description |
| ---------------------- | -------- | ----------- |
| `type` | no | The type of object to dump to the log.
When `start_log_objects` highlights the growth of a collection of objects in memory, this service can help investigate. The `repr` of each object that matches `type` will be logged.