Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support auto increase heap limit #217

Merged
merged 6 commits into from
Jan 10, 2023
Merged

Conversation

hyj1991
Copy link
Member

@hyj1991 hyj1991 commented Jan 10, 2023

背景

增加 enable_auto_incr_heap_limit 的配置,默认为 false 即不开启此特性。

如果开启 enable_auto_incr_heap_limittrue,则会使得 Node.js 进程在堆分配即将到达上限时可以自动增加 heap_limit 续命。

默认每次接近堆上限增加 256MBheap_limit,这个值可以通过 auto_heap_limit_size 来进行修改。

TODO

等到 Node.js 进程内存水位恢复正常后使用 RemoveNearHeapLimitCallback 重设 heap_limitinitial_heap_limit

namespace xprofiler {
static const char module_type[] = "heap_limit";

size_t NearHeapLimitCallback(void* data, size_t current_heap_limit,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

持续监听么?要不要增加一个 maxLimitation 的限制?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要,limit 其实只是一个值,它除了让 v8 判断是否需要 OOM,不会反映到实际内存上的

@codecov
Copy link

codecov bot commented Jan 10, 2023

Codecov Report

Merging #217 (f62d0ae) into master (dfab18f) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master      #217   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           10        10           
  Lines          317       318    +1     
=========================================
+ Hits           317       318    +1     
Impacted Files Coverage Δ
configuration.js 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@hyj1991 hyj1991 merged commit 8808b04 into X-Profiler:master Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants