lua-resty-timer icon indicating copy to clipboard operation
lua-resty-timer copied to clipboard

feat: option to recycle timer context

Open Tieske opened this issue 5 years ago • 1 comments

a timer context is implemented as a request under the hood. This means that it is supposed to be short-lived. As such some calls leak memory within a context, which is not a problem when the context is short-lived and freed as a whole. But if we hold on to timer contexts indefinitely, it becomes a real memory leak. Hence the new option to recycle the timer context after max_use number of invocations (by default 1000).

It is implemented in such a way that if the creation of the replacement timer fails (due to lack of timer resources), it will continue in the existing context. This makes the timer resilient to lack-of-timer-resource type errors.

Tieske avatar Dec 21 '20 14:12 Tieske

@locao since we figured this one out: https://github.com/Kong/lua-resty-timer/pull/11/files#diff-62bd0b4b2f58444dda4d468eb58071b931b443ddb4be4d9797c3cd2f61ca059bR34-R38 (credits to Javier), I think this is now good to go

Tieske avatar Aug 12 '21 15:08 Tieske