Manage memory allocations
If your code allocates memory for user data that the callback function needs, this memory must have a duration long enough to persist until the execution of the callback. Otherwise, the callback cannot access the user data. This user data might include information that the callback function needs to handle the event or to notify users of the cause of the event.
The following table shows the memory durations associated
with callback and event types.
Callback or event type | Memory duration to use |
---|---|
End-of-statement | PER_STMT_EXEC |
End-of-transaction | PER_TRANSACTION |
End-of-session | PER_SESSION |
MI_EVENT_POST_XACT | PER_TRANSACTION |
MI_EVENT_SAVEPOINT | PER_TRANSACTION |
MI_EVENT_COMMIT_ABORT | PER_TRANSACTION |
At the end of the memory duration associated with the callback, the database server deallocates the memory as part of its final cleanup.