From: Dmitry Volyntsev Date: Fri, 30 Oct 2026 01:48:58 +0000 (-0700) Subject: Modules: clarify context reuse memory check comment X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=1995b610fd2a298a6a7bd15723701995b6c8fd87;p=njs.git Modules: clarify context reuse memory check comment The comment claimed that the memory usage of a reused QuickJS runtime could only remain high if the global scope was modified. Values retained by engine internals and uncollected garbage are also counted, while memory outside of the runtime is not. --- diff --git a/nginx/ngx_js.c b/nginx/ngx_js.c index 5167a6d9..2eaaa9fc 100644 --- a/nginx/ngx_js.c +++ b/nginx/ngx_js.c @@ -1432,12 +1432,13 @@ ngx_engine_qjs_destroy(ngx_engine_t *e, ngx_js_ctx_t *ctx, /* * After the request object is freed, the runtime's memory usage should - * be low. It can only remain high if the global scope was - * modified. + * be low. It can remain high if values were retained, for example in + * the global scope, or if garbage was not yet collected. * * To prevent unlimited memory consumption growth, check whether memory * usage exceeds the configured limit. The check is performed rarely to * avoid performance impact of JS_ComputeMemoryUsage() which is slow. + * Memory outside of the runtime, such as nginx pools, is not counted. */ if ((ngx_random() & 0xff) == 1) {