Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Tôi sẽ chỉ ra cách giải quyết quá trình ra khỏi bộ nhớ trong node.js.

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed — process out of memory

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Cùng một vấn đề đầu ra với Node.js v6.7

Lỗi này xảy ra khi bộ nhớ được phân bổ cho ứng dụng thực thi nhỏ hơn bộ nhớ cần thiết khi chạy ứng dụng.

Theo mặc định, giới hạn bộ nhớ trong Node.js là 512 MB, để giải quyết vấn đề này, bạn cần tăng lệnh sử dụng giới hạn bộ nhớ

 node --max-old-space-size=4096 yourFile.js
3. Có thể tránh vấn đề giới hạn bộ nhớ.


node --max-old-space-size=1024 index.js #increase to 1gb
node --max-old-space-size=2048 index.js #increase to 2gb
node --max-old-space-size=3072 index.js #increase to 3gb
node --max-old-space-size=4096 index.js #increase to 4gb
node --max-old-space-size=5120 index.js #increase to 5gb
node --max-old-space-size=6144 index.js #increase to 6gb
node --max-old-space-size=7168 index.js #increase to 7gb
node --max-old-space-size=8192 index.js #increase to 8gb

Đó là nó. Mã hóa hạnh phúc!
Happy coding!

Hôm nay tôi đã chạy tập lệnh của mình để lập chỉ mục hệ thống tập tin để làm mới chỉ mục tệp RAID và sau 4h, nó đã bị lỗi với lỗi sau:

[md5:]  241613/241627 97.5%  
[md5:]  241614/241627 97.5%  
[md5:]  241625/241627 98.1%
Creating missing list... (79570 files missing)
Creating new files list... (241627 new files)

<--- Last few GCs --->

11629672 ms: Mark-sweep 1174.6 (1426.5) -> 1172.4 (1418.3) MB, 659.9 / 0 ms [allocation failure] [GC in old space requested].
11630371 ms: Mark-sweep 1172.4 (1418.3) -> 1172.4 (1411.3) MB, 698.9 / 0 ms [allocation failure] [GC in old space requested].
11631105 ms: Mark-sweep 1172.4 (1411.3) -> 1172.4 (1389.3) MB, 733.5 / 0 ms [last resort gc].
11631778 ms: Mark-sweep 1172.4 (1389.3) -> 1172.4 (1368.3) MB, 673.6 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3d1d329c9e59 
1: SparseJoinWithSeparatorJS(aka SparseJoinWithSeparatorJS) [native array.js:~84] [pc=0x3629ef689ad0] (this=0x3d1d32904189 ,w=0x2b690ce91071 ,L=241627,M=0x3d1d329b4a11 ,N=0x7c953bf4d49 )
2: Join(aka Join) [native array.js:143] [pc=0x3629ef616696] (this=0x3d1d32904189 

Máy chủ được trang bị RAM 16GB và hoán đổi SSD 24GB. Tôi rất nghi ngờ kịch bản của tôi vượt quá 36GB bộ nhớ. Ít nhất nó không nên

Tập lệnh tạo chỉ mục của các tệp được lưu trữ dưới dạng mảng các đối tượng với siêu dữ liệu (ngày sửa đổi, quyền, v.v., không có dữ liệu lớn)

Đây là mã tập lệnh đầy đủ: http://pastebin.com/mjad76c3

Tôi đã thử nghiệm các vấn đề về nút kỳ lạ trong quá khứ với tập lệnh này, những gì đã buộc tôi. Chia chỉ mục thành nhiều tệp khi nút bị trục trặc khi làm việc trên các tệp lớn như chuỗi. Có cách nào để cải thiện quản lý bộ nhớ NodeJS với các bộ dữ liệu khổng lồ không?

Hỏi ngày 25 tháng 7 năm 2016 lúc 2:45Jul 25, 2016 at 2:45

2

Nếu tôi nhớ chính xác, có một giới hạn tiêu chuẩn nghiêm ngặt cho việc sử dụng bộ nhớ trong V8 khoảng 1,7 GB, nếu bạn không tăng thủ công.

Trong một trong những sản phẩm của chúng tôi, chúng tôi đã theo dõi giải pháp này trong tập lệnh triển khai của chúng tôi:

 node --max-old-space-size=4096 yourFile.js

Cũng sẽ có một lệnh không gian mới nhưng như tôi đã đọc ở đây: Bộ sưu tập Bam-tour-of-of-of-V8, không gian mới chỉ thu thập dữ liệu ngắn hạn mới được tạo và không gian cũ chứa tất cả các cấu trúc dữ liệu được tham chiếu nên có trong Trường hợp của bạn là lựa chọn tốt nhất.

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Đã trả lời ngày 25 tháng 7 năm 2016 lúc 5:29Jul 25, 2016 at 5:29

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

FelixfelixFelix

5.0811 Huy hiệu vàng9 Huy hiệu bạc17 Huy hiệu đồng1 gold badge9 silver badges17 bronze badges

8

Nếu bạn muốn tăng mức sử dụng bộ nhớ của nút trên toàn cầu - không chỉ một tập lệnh duy nhất, bạn có thể xuất biến môi trường, như thế này:

 node --max-old-space-size=4096 yourFile.js
4
 node --max-old-space-size=4096 yourFile.js
4

Sau đó, bạn không cần chơi với các tệp khi chạy các bản dựng như

 node --max-old-space-size=4096 yourFile.js
5.

Đã trả lời ngày 23 tháng 11 năm 2018 lúc 8:56Nov 23, 2018 at 8:56

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Maksim Luzikmaksim LuzikMaksim Luzik

5.3534 Huy hiệu vàng35 Huy hiệu bạc56 Huy hiệu Đồng4 gold badges35 silver badges56 bronze badges

3

Chỉ trong trường hợp bất kỳ ai chạy vào điều này trong một môi trường mà họ không thể đặt các thuộc tính nút trực tiếp (trong trường hợp của tôi là một công cụ xây dựng):

NODE_OPTIONS="--max-old-space-size=4096" node ...

Bạn có thể đặt các tùy chọn nút bằng biến môi trường nếu bạn không thể truyền chúng trên dòng lệnh.

Đã trả lời ngày 18 tháng 9 năm 2018 lúc 15:55Sep 18, 2018 at 15:55

Kamiel Wanrooijkamiel WanrooijKamiel Wanrooij

Huy hiệu vàng 12k635 Huy hiệu bạc43 Huy hiệu đồng6 gold badges35 silver badges43 bronze badges

3

Dưới đây là một số giá trị cờ để thêm một số thông tin bổ sung về cách cho phép nhiều bộ nhớ hơn khi bạn khởi động máy chủ nút của mình.

1GB - 8GB

#increase to 1gb
node --max-old-space-size=1024 index.js

#increase to 2gb
node --max-old-space-size=2048 index.js 

#increase to 3gb
node --max-old-space-size=3072 index.js

#increase to 4gb
node --max-old-space-size=4096 index.js

#increase to 5gb
node --max-old-space-size=5120 index.js

#increase to 6gb
node --max-old-space-size=6144 index.js

#increase to 7gb
node --max-old-space-size=7168 index.js

#increase to 8gb 
node --max-old-space-size=8192 index.js 

Đã trả lời ngày 13 tháng 2 năm 2019 lúc 17:12Feb 13, 2019 at 17:12

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Nicholas Porternicholas PorterNicholas Porter

2.0582 Huy hiệu vàng18 Huy hiệu bạc31 Huy hiệu đồng2 gold badges18 silver badges31 bronze badges

4

Tôi chỉ phải đối mặt với vấn đề tương tự với phiên bản EC2 của mình T2.micro có bộ nhớ 1 GB.

Tôi đã giải quyết vấn đề bằng cách tạo tệp hoán đổi bằng URL này và đặt biến môi trường sau.

 node --max-old-space-size=4096 yourFile.js
4

Cuối cùng vấn đề đã biến mất.

Tôi hy vọng điều đó sẽ hữu ích cho tương lai.

Đã trả lời ngày 17 tháng 4 năm 2020 lúc 2:57Apr 17, 2020 at 2:57

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

4

Tôi đã đấu tranh với điều này ngay cả sau khi thiết lập--Max-cũ-Space-Size.

Sau đó, tôi nhận ra cần đặt các tùy chọn--Max-Old-Space-Size trước kịch bản nghiệp.

Ngoài ra, tốt nhất để chỉ định cả hai cú pháp--Max-cũ-Space-Size và--Max_old_Space_Size của tôi tập lệnh của tôi cho Karma:

node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192  --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192   --prod --aot

Tham khảo https://github.com/angular/angular-cli/issues/1652

Đã trả lời ngày 22 tháng 6 năm 2017 lúc 8:43Jun 22, 2017 at 8:43

Duchuyduchuyduchuy

5764 Huy hiệu bạc9 Huy hiệu Đồng4 silver badges9 bronze badges

4

Tôi đã gặp phải vấn đề này khi cố gắng gỡ lỗi với VSCode, vì vậy chỉ muốn thêm đây là cách bạn có thể thêm đối số vào thiết lập gỡ lỗi của bạn.

Bạn có thể thêm nó vào thuộc tính

 node --max-old-space-size=4096 yourFile.js
7 của cấu hình của bạn trong
 node --max-old-space-size=4096 yourFile.js
8.

Xem ví dụ dưới đây.

{
"version": "0.2.0",
"configurations": [{
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "program": "${workspaceRoot}\\server.js"
    },
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Training Script",
        "program": "${workspaceRoot}\\training-script.js",
        "runtimeArgs": [
            "--max-old-space-size=4096"
        ]
    }
]}

Đã trả lời ngày 20 tháng 6 năm 2017 lúc 1:26Jun 20, 2017 at 1:26

Astr-oAstr-oAstr-o

4954 Huy hiệu bạc10 Huy hiệu đồng4 silver badges10 bronze badges

3

Tôi đã phải đối mặt với vấn đề tương tự gần đây và gặp phải chủ đề này nhưng vấn đề của tôi là với ứng dụng

 node --max-old-space-size=4096 yourFile.js
9. Dưới đây thay đổi trong lệnh bắt đầu nút đã giải quyết các vấn đề của tôi.

Cú pháp

node --max-old-space-size= path-to/fileName.js

Thí dụ

node --max-old-space-size=16000 scripts/build.js

Tại sao kích thước là 16000 trong kích thước không gian tối đa?

Về cơ bản, nó thay đổi tùy thuộc vào bộ nhớ được phân bổ cho chuỗi đó và cài đặt nút của bạn.

Làm thế nào để xác minh và cung cấp kích thước đúng?

Điều này về cơ bản là ở trong động cơ của chúng tôi

NODE_OPTIONS="--max-old-space-size=4096" node ...
0. Mã dưới đây giúp bạn hiểu kích thước heap của động cơ V8 Node V8 của bạn.


node --max-old-space-size=1024 index.js #increase to 1gb
node --max-old-space-size=2048 index.js #increase to 2gb
node --max-old-space-size=3072 index.js #increase to 3gb
node --max-old-space-size=4096 index.js #increase to 4gb
node --max-old-space-size=5120 index.js #increase to 5gb
node --max-old-space-size=6144 index.js #increase to 6gb
node --max-old-space-size=7168 index.js #increase to 7gb
node --max-old-space-size=8192 index.js #increase to 8gb
0

Đã trả lời ngày 13 tháng 8 năm 2019 lúc 15:24Aug 13, 2019 at 15:24

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Venkat.RVenkat.RVenkat.R

7.2505 Huy hiệu vàng40 Huy hiệu bạc63 Huy hiệu Đồng5 gold badges40 silver badges63 bronze badges

Tôi chỉ muốn thêm rằng trong một số hệ thống, thậm chí tăng giới hạn bộ nhớ nút với

NODE_OPTIONS="--max-old-space-size=4096" node ...
1, nó là không đủ và có một lỗi hệ điều hành như thế này:


node --max-old-space-size=1024 index.js #increase to 1gb
node --max-old-space-size=2048 index.js #increase to 2gb
node --max-old-space-size=3072 index.js #increase to 3gb
node --max-old-space-size=4096 index.js #increase to 4gb
node --max-old-space-size=5120 index.js #increase to 5gb
node --max-old-space-size=6144 index.js #increase to 6gb
node --max-old-space-size=7168 index.js #increase to 7gb
node --max-old-space-size=8192 index.js #increase to 8gb
1

Trong trường hợp này, có lẽ là vì bạn đã đạt được MAX MMAP cho mỗi quá trình.

Bạn có thể kiểm tra MAX_MAP_COUNT bằng cách chạy


node --max-old-space-size=1024 index.js #increase to 1gb
node --max-old-space-size=2048 index.js #increase to 2gb
node --max-old-space-size=3072 index.js #increase to 3gb
node --max-old-space-size=4096 index.js #increase to 4gb
node --max-old-space-size=5120 index.js #increase to 5gb
node --max-old-space-size=6144 index.js #increase to 6gb
node --max-old-space-size=7168 index.js #increase to 7gb
node --max-old-space-size=8192 index.js #increase to 8gb
2

và tăng nó bằng cách chạy


node --max-old-space-size=1024 index.js #increase to 1gb
node --max-old-space-size=2048 index.js #increase to 2gb
node --max-old-space-size=3072 index.js #increase to 3gb
node --max-old-space-size=4096 index.js #increase to 4gb
node --max-old-space-size=5120 index.js #increase to 5gb
node --max-old-space-size=6144 index.js #increase to 6gb
node --max-old-space-size=7168 index.js #increase to 7gb
node --max-old-space-size=8192 index.js #increase to 8gb
3

và sửa nó để không được đặt lại sau khi khởi động lại bằng cách thêm dòng này


node --max-old-space-size=1024 index.js #increase to 1gb
node --max-old-space-size=2048 index.js #increase to 2gb
node --max-old-space-size=3072 index.js #increase to 3gb
node --max-old-space-size=4096 index.js #increase to 4gb
node --max-old-space-size=5120 index.js #increase to 5gb
node --max-old-space-size=6144 index.js #increase to 6gb
node --max-old-space-size=7168 index.js #increase to 7gb
node --max-old-space-size=8192 index.js #increase to 8gb
4

Trong tệp

NODE_OPTIONS="--max-old-space-size=4096" node ...
2.

Kiểm tra ở đây để biết thêm thông tin.

Một phương pháp tốt để phân tích lỗi là chạy quy trình với

NODE_OPTIONS="--max-old-space-size=4096" node ...
3


node --max-old-space-size=1024 index.js #increase to 1gb
node --max-old-space-size=2048 index.js #increase to 2gb
node --max-old-space-size=3072 index.js #increase to 3gb
node --max-old-space-size=4096 index.js #increase to 4gb
node --max-old-space-size=5120 index.js #increase to 5gb
node --max-old-space-size=6144 index.js #increase to 6gb
node --max-old-space-size=7168 index.js #increase to 7gb
node --max-old-space-size=8192 index.js #increase to 8gb
5

Đã trả lời ngày 26 tháng 1 năm 2020 lúc 23:55Jan 26, 2020 at 23:55

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Jbaylinajbaylinajbaylina

4.1581 Huy hiệu vàng29 Huy hiệu bạc39 Huy hiệu đồng1 gold badge29 silver badges39 bronze badges

2

Các bước để khắc phục sự cố này (trong Windows) -

  1. Mở dấu nhắc lệnh và nhập
    NODE_OPTIONS="--max-old-space-size=4096" node ...
    
    4 Nhấn Enter
  2. Điều hướng đến thư mục
    NODE_OPTIONS="--max-old-space-size=4096" node ...
    
    4> NPM
  3. Mở hoặc chỉnh sửa
    NODE_OPTIONS="--max-old-space-size=4096" node ...
    
    6 trong trình soạn thảo yêu thích của bạn
  4. Thêm
    NODE_OPTIONS="--max-old-space-size=4096" node ...
    
    7 vào khối if và khác

Tệp

NODE_OPTIONS="--max-old-space-size=4096" node ...
8 của bạn trông như thế này sau khi thay đổi:


node --max-old-space-size=1024 index.js #increase to 1gb
node --max-old-space-size=2048 index.js #increase to 2gb
node --max-old-space-size=3072 index.js #increase to 3gb
node --max-old-space-size=4096 index.js #increase to 4gb
node --max-old-space-size=5120 index.js #increase to 5gb
node --max-old-space-size=6144 index.js #increase to 6gb
node --max-old-space-size=7168 index.js #increase to 7gb
node --max-old-space-size=8192 index.js #increase to 8gb
6

Đã trả lời ngày 19 tháng 10 năm 2018 lúc 5:30Oct 19, 2018 at 5:30

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Umang Patwaumang PatwaUmang Patwa

2.5653 huy hiệu vàng29 Huy hiệu bạc39 Huy hiệu đồng3 gold badges29 silver badges39 bronze badges

0

Gần đây, trong một trong những dự án của tôi đã gặp phải vấn đề tương tự. Đã thử một vài điều mà bất cứ ai cũng có thể thử làm gỡ lỗi để xác định nguyên nhân gốc rễ:

  1. Như mọi người đã đề xuất, hãy tăng giới hạn bộ nhớ trong nút bằng cách thêm lệnh này:


    node --max-old-space-size=1024 index.js #increase to 1gb
    node --max-old-space-size=2048 index.js #increase to 2gb
    node --max-old-space-size=3072 index.js #increase to 3gb
    node --max-old-space-size=4096 index.js #increase to 4gb
    node --max-old-space-size=5120 index.js #increase to 5gb
    node --max-old-space-size=6144 index.js #increase to 6gb
    node --max-old-space-size=7168 index.js #increase to 7gb
    node --max-old-space-size=8192 index.js #increase to 8gb
    7

Ở đây

NODE_OPTIONS="--max-old-space-size=4096" node ...
9 Tôi đã xác định cho ứng dụng của mình là 1536 (vì bộ nhớ pod Kubernetes của tôi là giới hạn 2 GB, yêu cầu 1,5 GB)

Vì vậy, luôn luôn xác định

NODE_OPTIONS="--max-old-space-size=4096" node ...
9 dựa trên giới hạn cơ sở hạ tầng/kiến trúc frontend của bạn (ít hơn một chút so với giới hạn)

Một chú thích nghiêm ngặt ở đây trong lệnh trên, sử dụng

NODE_OPTIONS="--max-old-space-size=4096" node ...
1 sau lệnh
#increase to 1gb
node --max-old-space-size=1024 index.js

#increase to 2gb
node --max-old-space-size=2048 index.js 

#increase to 3gb
node --max-old-space-size=3072 index.js

#increase to 4gb
node --max-old-space-size=4096 index.js

#increase to 5gb
node --max-old-space-size=5120 index.js

#increase to 6gb
node --max-old-space-size=6144 index.js

#increase to 7gb
node --max-old-space-size=7168 index.js

#increase to 8gb 
node --max-old-space-size=8192 index.js 

2 không theo tên tệp
#increase to 1gb
node --max-old-space-size=1024 index.js

#increase to 2gb
node --max-old-space-size=2048 index.js 

#increase to 3gb
node --max-old-space-size=3072 index.js

#increase to 4gb
node --max-old-space-size=4096 index.js

#increase to 5gb
node --max-old-space-size=5120 index.js

#increase to 6gb
node --max-old-space-size=6144 index.js

#increase to 7gb
node --max-old-space-size=7168 index.js

#increase to 8gb 
node --max-old-space-size=8192 index.js 

3.

  1. Nếu bạn có tệp cấu hình

    #increase to 1gb
    node --max-old-space-size=1024 index.js
    
    #increase to 2gb
    node --max-old-space-size=2048 index.js 
    
    #increase to 3gb
    node --max-old-space-size=3072 index.js
    
    #increase to 4gb
    node --max-old-space-size=4096 index.js
    
    #increase to 5gb
    node --max-old-space-size=5120 index.js
    
    #increase to 6gb
    node --max-old-space-size=6144 index.js
    
    #increase to 7gb
    node --max-old-space-size=7168 index.js
    
    #increase to 8gb 
    node --max-old-space-size=8192 index.js 
    
    
    4 thì hãy kiểm tra những điều sau:

    • worker_connections:

      #increase to 1gb
      node --max-old-space-size=1024 index.js
      
      #increase to 2gb
      node --max-old-space-size=2048 index.js 
      
      #increase to 3gb
      node --max-old-space-size=3072 index.js
      
      #increase to 4gb
      node --max-old-space-size=4096 index.js
      
      #increase to 5gb
      node --max-old-space-size=5120 index.js
      
      #increase to 6gb
      node --max-old-space-size=6144 index.js
      
      #increase to 7gb
      node --max-old-space-size=7168 index.js
      
      #increase to 8gb 
      node --max-old-space-size=8192 index.js 
      
      
      5 (đối với các ứng dụng phía trước hạng nặng) [NGINX mặc định là
      #increase to 1gb
      node --max-old-space-size=1024 index.js
      
      #increase to 2gb
      node --max-old-space-size=2048 index.js 
      
      #increase to 3gb
      node --max-old-space-size=3072 index.js
      
      #increase to 4gb
      node --max-old-space-size=4096 index.js
      
      #increase to 5gb
      node --max-old-space-size=5120 index.js
      
      #increase to 6gb
      node --max-old-space-size=6144 index.js
      
      #increase to 7gb
      node --max-old-space-size=7168 index.js
      
      #increase to 8gb 
      node --max-old-space-size=8192 index.js 
      
      
      6 kết nối trên mỗi
      #increase to 1gb
      node --max-old-space-size=1024 index.js
      
      #increase to 2gb
      node --max-old-space-size=2048 index.js 
      
      #increase to 3gb
      node --max-old-space-size=3072 index.js
      
      #increase to 4gb
      node --max-old-space-size=4096 index.js
      
      #increase to 5gb
      node --max-old-space-size=5120 index.js
      
      #increase to 6gb
      node --max-old-space-size=6144 index.js
      
      #increase to 7gb
      node --max-old-space-size=7168 index.js
      
      #increase to 8gb 
      node --max-old-space-size=8192 index.js 
      
      
      7, quá thấp cho các ứng dụng hiện đại]

    • Sử dụng:

      #increase to 1gb
      node --max-old-space-size=1024 index.js
      
      #increase to 2gb
      node --max-old-space-size=2048 index.js 
      
      #increase to 3gb
      node --max-old-space-size=3072 index.js
      
      #increase to 4gb
      node --max-old-space-size=4096 index.js
      
      #increase to 5gb
      node --max-old-space-size=5120 index.js
      
      #increase to 6gb
      node --max-old-space-size=6144 index.js
      
      #increase to 7gb
      node --max-old-space-size=7168 index.js
      
      #increase to 8gb 
      node --max-old-space-size=8192 index.js 
      
      
      8 (Phương pháp hiệu quả) [NGINX hỗ trợ nhiều phương pháp xử lý kết nối]]

    • HTTP: Thêm những điều sau đây để giải phóng nhân viên của bạn khỏi việc bận rộn trong việc xử lý một số nhiệm vụ không mong muốn. .client_body_timeout , reset_timeout_connection , client_header_timeout,keepalive_timeout ,send_timeout).

  2. Xóa tất cả các công cụ ghi nhật ký/theo dõi như

    #increase to 1gb
    node --max-old-space-size=1024 index.js
    
    #increase to 2gb
    node --max-old-space-size=2048 index.js 
    
    #increase to 3gb
    node --max-old-space-size=3072 index.js
    
    #increase to 4gb
    node --max-old-space-size=4096 index.js
    
    #increase to 5gb
    node --max-old-space-size=5120 index.js
    
    #increase to 6gb
    node --max-old-space-size=6144 index.js
    
    #increase to 7gb
    node --max-old-space-size=7168 index.js
    
    #increase to 8gb 
    node --max-old-space-size=8192 index.js 
    
    
    9 (SEO), v.v.middlewares or turn off.

  3. Bây giờ gỡ lỗi mức mã: Trong tệp

    node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192  --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192   --prod --aot
    
    0 chính của bạn, hãy xóa không mong muốn
    node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192  --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192   --prod --aot
    
    1 chỉ là in một tin nhắn.
    : In your main
    node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192  --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192   --prod --aot
    
    0 file , remove unwanted
    node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192  --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192   --prod --aot
    
    1 which is just printing a message.

  4. Bây giờ hãy kiểm tra mọi tuyến máy chủ I.E

    node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192  --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192   --prod --aot
    
    2 bên dưới các kịch bản:

  • node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192  --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192   --prod --aot
    
    3 // Bạn có thực sự cần phải chờ dữ liệu hoặc API đó trả về một cái gì đó để trả lời mà tôi phải chờ không ?? , Nếu không sửa đổi như thế này:

node --max-old-space-size=1024 index.js #increase to 1gb
node --max-old-space-size=2048 index.js #increase to 2gb
node --max-old-space-size=3072 index.js #increase to 3gb
node --max-old-space-size=4096 index.js #increase to 4gb
node --max-old-space-size=5120 index.js #increase to 5gb
node --max-old-space-size=6144 index.js #increase to 6gb
node --max-old-space-size=7168 index.js #increase to 7gb
node --max-old-space-size=8192 index.js #increase to 8gb
8
  • Phần khác: Nếu không có lỗi nào thì chỉ đơn giản là

    node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192  --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192   --prod --aot
    
    4, không
    node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192  --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192   --prod --aot
    
    5.NO
    node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192  --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192   --prod --aot
    
    5.

  • Lỗi Phần: Một số người định nghĩa là

    node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192  --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192   --prod --aot
    
    6 hoặc
    node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192  --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192   --prod --aot
    
    7 tạo ra sự nhầm lẫn và sai lầm. như thế này:


    node --max-old-space-size=1024 index.js #increase to 1gb
    node --max-old-space-size=2048 index.js #increase to 2gb
    node --max-old-space-size=3072 index.js #increase to 3gb
    node --max-old-space-size=4096 index.js #increase to 4gb
    node --max-old-space-size=5120 index.js #increase to 5gb
    node --max-old-space-size=6144 index.js #increase to 6gb
    node --max-old-space-size=7168 index.js #increase to 7gb
    node --max-old-space-size=8192 index.js #increase to 8gb
    9
  • Xóa

    node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192  --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192   --prod --aot
    
    8,
    node --max-old-space-size=8192 --optimize-for-size --max-executable-size=8192  --max_old_space_size=8192 --optimize_for_size --max_executable_size=8192 node_modules/karma/bin/karma start --single-run --max_new_space_size=8192   --prod --aot
    
    9 Các thư viện không sử dụng khác bằng lệnh
    {
    "version": "0.2.0",
    "configurations": [{
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}\\server.js"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Training Script",
            "program": "${workspaceRoot}\\training-script.js",
            "runtimeArgs": [
                "--max-old-space-size=4096"
            ]
        }
    ]}
    
    0.

  • Trong tệp dịch vụ Axios, hãy kiểm tra các phương thức và đăng nhập đúng cách hoặc không thích:

    [md5:]  241613/241627 97.5%  
    [md5:]  241614/241627 97.5%  
    [md5:]  241625/241627 98.1%
    Creating missing list... (79570 files missing)
    Creating new files list... (241627 new files)
    
    <--- Last few GCs --->
    
    11629672 ms: Mark-sweep 1174.6 (1426.5) -> 1172.4 (1418.3) MB, 659.9 / 0 ms [allocation failure] [GC in old space requested].
    11630371 ms: Mark-sweep 1172.4 (1418.3) -> 1172.4 (1411.3) MB, 698.9 / 0 ms [allocation failure] [GC in old space requested].
    11631105 ms: Mark-sweep 1172.4 (1411.3) -> 1172.4 (1389.3) MB, 733.5 / 0 ms [last resort gc].
    11631778 ms: Mark-sweep 1172.4 (1389.3) -> 1172.4 (1368.3) MB, 673.6 / 0 ms [last resort gc].
    
    
    <--- JS stacktrace --->
    
    ==== JS stack trace =========================================
    
    Security context: 0x3d1d329c9e59 
    1: SparseJoinWithSeparatorJS(aka SparseJoinWithSeparatorJS) [native array.js:~84] [pc=0x3629ef689ad0] (this=0x3d1d32904189 ,w=0x2b690ce91071 ,L=241627,M=0x3d1d329b4a11 ,N=0x7c953bf4d49 )
    2: Join(aka Join) [native array.js:143] [pc=0x3629ef616696] (this=0x3d1d32904189 
    0
  • Tiết kiệm bản thân khỏi việc sử dụng

    {
    "version": "0.2.0",
    "configurations": [{
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}\\server.js"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Training Script",
            "program": "${workspaceRoot}\\training-script.js",
            "runtimeArgs": [
                "--max-old-space-size=4096"
            ]
        }
    ]}
    
    1, vv trên bộ dữ liệu lớn. (mà tôi cũng có thể thấy trong nhật ký hiển thị ở trên của bạn.

  1. Cuối cùng nhưng không kém phần quan trọng, trong mỗi lần ứng dụng của bạn gặp sự cố hoặc POD được khởi động lại, hãy kiểm tra nhật ký. Trong nhật ký đặc biệt tìm kiếm phần này:
    {
    "version": "0.2.0",
    "configurations": [{
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}\\server.js"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Training Script",
            "program": "${workspaceRoot}\\training-script.js",
            "runtimeArgs": [
                "--max-old-space-size=4096"
            ]
        }
    ]}
    
    2 Điều này sẽ cung cấp cho bạn lý do, ở đâu và ai là thủ phạm đằng sau vụ tai nạn.
    {
    "version": "0.2.0",
    "configurations": [{
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}\\server.js"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Training Script",
            "program": "${workspaceRoot}\\training-script.js",
            "runtimeArgs": [
                "--max-old-space-size=4096"
            ]
        }
    ]}
    
    2
    This will give you why , where and who is the culprit behind the crash.

Đã trả lời ngày 2 tháng 4 năm 2021 lúc 5:02Apr 2, 2021 at 5:02

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Sidvermasidvermasidverma

1.08311 huy hiệu bạc21 Huy hiệu đồng11 silver badges21 bronze badges

Tôi sẽ đề cập đến 2 loại giải pháp.

Giải pháp của tôi: Trong trường hợp của tôi, tôi thêm điều này vào các biến môi trường của mình:

[md5:]  241613/241627 97.5%  
[md5:]  241614/241627 97.5%  
[md5:]  241625/241627 98.1%
Creating missing list... (79570 files missing)
Creating new files list... (241627 new files)

<--- Last few GCs --->

11629672 ms: Mark-sweep 1174.6 (1426.5) -> 1172.4 (1418.3) MB, 659.9 / 0 ms [allocation failure] [GC in old space requested].
11630371 ms: Mark-sweep 1172.4 (1418.3) -> 1172.4 (1411.3) MB, 698.9 / 0 ms [allocation failure] [GC in old space requested].
11631105 ms: Mark-sweep 1172.4 (1411.3) -> 1172.4 (1389.3) MB, 733.5 / 0 ms [last resort gc].
11631778 ms: Mark-sweep 1172.4 (1389.3) -> 1172.4 (1368.3) MB, 673.6 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3d1d329c9e59 
1: SparseJoinWithSeparatorJS(aka SparseJoinWithSeparatorJS) [native array.js:~84] [pc=0x3629ef689ad0] (this=0x3d1d32904189 ,w=0x2b690ce91071 ,L=241627,M=0x3d1d329b4a11 ,N=0x7c953bf4d49 )
2: Join(aka Join) [native array.js:143] [pc=0x3629ef616696] (this=0x3d1d32904189 
1

Nhưng ngay cả khi tôi khởi động lại máy tính của mình, nó vẫn không hoạt động. Thư mục dự án của tôi nằm trong d: \ đĩa. Vì vậy, tôi loại bỏ dự án của mình thành C: \ Disk và nó đã hoạt động.

Giải pháp của đồng đội của tôi: Cấu hình Pack.Json cũng được hoạt động.

[md5:]  241613/241627 97.5%  
[md5:]  241614/241627 97.5%  
[md5:]  241625/241627 98.1%
Creating missing list... (79570 files missing)
Creating new files list... (241627 new files)

<--- Last few GCs --->

11629672 ms: Mark-sweep 1174.6 (1426.5) -> 1172.4 (1418.3) MB, 659.9 / 0 ms [allocation failure] [GC in old space requested].
11630371 ms: Mark-sweep 1172.4 (1418.3) -> 1172.4 (1411.3) MB, 698.9 / 0 ms [allocation failure] [GC in old space requested].
11631105 ms: Mark-sweep 1172.4 (1411.3) -> 1172.4 (1389.3) MB, 733.5 / 0 ms [last resort gc].
11631778 ms: Mark-sweep 1172.4 (1389.3) -> 1172.4 (1368.3) MB, 673.6 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3d1d329c9e59 
1: SparseJoinWithSeparatorJS(aka SparseJoinWithSeparatorJS) [native array.js:~84] [pc=0x3629ef689ad0] (this=0x3d1d32904189 ,w=0x2b690ce91071 ,L=241627,M=0x3d1d329b4a11 ,N=0x7c953bf4d49 )
2: Join(aka Join) [native array.js:143] [pc=0x3629ef616696] (this=0x3d1d32904189 
2

Đã trả lời ngày 10 tháng 8 năm 2021 lúc 13:09Aug 10, 2021 at 13:09

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Cansucansucansu

1.0328 Huy hiệu bạc20 Huy hiệu Đồng8 silver badges20 bronze badges

1

Đối với những người mới bắt đầu khác như tôi, người không tìm thấy bất kỳ giải pháp phù hợp nào cho lỗi này, hãy kiểm tra phiên bản nút được cài đặt (x32, x64, x86). Tôi có CPU 64 bit và tôi đã cài đặt phiên bản nút x86, gây ra lỗi

{
"version": "0.2.0",
"configurations": [{
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "program": "${workspaceRoot}\\server.js"
    },
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Training Script",
        "program": "${workspaceRoot}\\training-script.js",
        "runtimeArgs": [
            "--max-old-space-size=4096"
        ]
    }
]}
3.node version installed (x32, x64, x86). I have a 64-bit CPU and I've installed x86 node version, which caused the
{
"version": "0.2.0",
"configurations": [{
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "program": "${workspaceRoot}\\server.js"
    },
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Training Script",
        "program": "${workspaceRoot}\\training-script.js",
        "runtimeArgs": [
            "--max-old-space-size=4096"
        ]
    }
]}
3 error.

Đã trả lời ngày 22 tháng 9 năm 2020 lúc 22:33Sep 22, 2020 at 22:33

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Nếu bạn muốn thay đổi bộ nhớ trên toàn cầu cho nút (Windows), hãy đến Cài đặt hệ thống nâng cao -> Biến môi trường -> Biến người dùng mới

[md5:]  241613/241627 97.5%  
[md5:]  241614/241627 97.5%  
[md5:]  241625/241627 98.1%
Creating missing list... (79570 files missing)
Creating new files list... (241627 new files)

<--- Last few GCs --->

11629672 ms: Mark-sweep 1174.6 (1426.5) -> 1172.4 (1418.3) MB, 659.9 / 0 ms [allocation failure] [GC in old space requested].
11630371 ms: Mark-sweep 1172.4 (1418.3) -> 1172.4 (1411.3) MB, 698.9 / 0 ms [allocation failure] [GC in old space requested].
11631105 ms: Mark-sweep 1172.4 (1411.3) -> 1172.4 (1389.3) MB, 733.5 / 0 ms [last resort gc].
11631778 ms: Mark-sweep 1172.4 (1389.3) -> 1172.4 (1368.3) MB, 673.6 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3d1d329c9e59 
1: SparseJoinWithSeparatorJS(aka SparseJoinWithSeparatorJS) [native array.js:~84] [pc=0x3629ef689ad0] (this=0x3d1d32904189 ,w=0x2b690ce91071 ,L=241627,M=0x3d1d329b4a11 ,N=0x7c953bf4d49 )
2: Join(aka Join) [native array.js:143] [pc=0x3629ef616696] (this=0x3d1d32904189 
3

Đã trả lời ngày 23 tháng 9 năm 2019 lúc 14:38Sep 23, 2019 at 14:38

Ahmed Aboudahmed AboudAhmed Aboud

1.13413 Huy hiệu bạc18 Huy hiệu đồng13 silver badges18 bronze badges

0

Bạn cũng có thể thay đổi các biến môi trường của cửa sổ bằng:

[md5:]  241613/241627 97.5%  
[md5:]  241614/241627 97.5%  
[md5:]  241625/241627 98.1%
Creating missing list... (79570 files missing)
Creating new files list... (241627 new files)

<--- Last few GCs --->

11629672 ms: Mark-sweep 1174.6 (1426.5) -> 1172.4 (1418.3) MB, 659.9 / 0 ms [allocation failure] [GC in old space requested].
11630371 ms: Mark-sweep 1172.4 (1418.3) -> 1172.4 (1411.3) MB, 698.9 / 0 ms [allocation failure] [GC in old space requested].
11631105 ms: Mark-sweep 1172.4 (1411.3) -> 1172.4 (1389.3) MB, 733.5 / 0 ms [last resort gc].
11631778 ms: Mark-sweep 1172.4 (1389.3) -> 1172.4 (1368.3) MB, 673.6 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3d1d329c9e59 
1: SparseJoinWithSeparatorJS(aka SparseJoinWithSeparatorJS) [native array.js:~84] [pc=0x3629ef689ad0] (this=0x3d1d32904189 ,w=0x2b690ce91071 ,L=241627,M=0x3d1d329b4a11 ,N=0x7c953bf4d49 )
2: Join(aka Join) [native array.js:143] [pc=0x3629ef616696] (this=0x3d1d32904189 
4

Đã trả lời ngày 17 tháng 10 năm 2020 lúc 17:47Oct 17, 2020 at 17:47

FiringblanksfiresblanksFiringBlanks

1.8504 huy hiệu vàng30 huy hiệu bạc44 Huy hiệu đồng4 gold badges30 silver badges44 bronze badges

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Unix (Mac OS) (Mac OS)

  1. Mở một thiết bị đầu cuối và mở tệp .zshrc của chúng tôi bằng Nano như vậy (điều này sẽ tạo một, nếu không tồn tại):.zshrc file using nano like so (this will create one, if one doesn't exist):

    {
    "version": "0.2.0",
    "configurations": [{
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}\\server.js"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Training Script",
            "program": "${workspaceRoot}\\training-script.js",
            "runtimeArgs": [
                "--max-old-space-size=4096"
            ]
        }
    ]}
    
    4

  2. Cập nhật biến môi trường Node_Options của chúng tôi bằng cách thêm dòng sau vào tệp .zshrc hiện đang mở của chúng tôi:NODE_OPTIONS environment variable by adding the following line into our currently open .zshrc file:

    {
    "version": "0.2.0",
    "configurations": [{
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}\\server.js"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Training Script",
            "program": "${workspaceRoot}\\training-script.js",
            "runtimeArgs": [
                "--max-old-space-size=4096"
            ]
        }
    ]}
    
    5

Xin lưu ý rằng chúng tôi có thể đặt số lượng megabyte được truyền vào bất cứ thứ gì chúng tôi thích, với điều kiện hệ thống của chúng tôi có đủ bộ nhớ (ở đây chúng tôi đang vượt qua 8192 megabyte khoảng 8 GB).

  1. Lưu và thoát Nano bằng cách nhấn:

    {
    "version": "0.2.0",
    "configurations": [{
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}\\server.js"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Training Script",
            "program": "${workspaceRoot}\\training-script.js",
            "runtimeArgs": [
                "--max-old-space-size=4096"
            ]
        }
    ]}
    
    6, sau đó
    {
    "version": "0.2.0",
    "configurations": [{
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}\\server.js"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Training Script",
            "program": "${workspaceRoot}\\training-script.js",
            "runtimeArgs": [
                "--max-old-space-size=4096"
            ]
        }
    ]}
    
    7 để đồng ý và cuối cùng là
    {
    "version": "0.2.0",
    "configurations": [{
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}\\server.js"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Training Script",
            "program": "${workspaceRoot}\\training-script.js",
            "runtimeArgs": [
                "--max-old-space-size=4096"
            ]
        }
    ]}
    
    8 để lưu các thay đổi.

  2. Đóng và mở lại thiết bị đầu cuối để đảm bảo những thay đổi của chúng tôi đã được công nhận. and reopen the terminal to make sure our changes have been recognised.

  3. Chúng tôi có thể in nội dung của tệp .zshrc của chúng tôi để xem liệu các thay đổi của chúng tôi có được lưu như vậy không như vậy:

    {
    "version": "0.2.0",
    "configurations": [{
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}\\server.js"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Training Script",
            "program": "${workspaceRoot}\\training-script.js",
            "runtimeArgs": [
                "--max-old-space-size=4096"
            ]
        }
    ]}
    
    9.print out the contents of our .zshrc file to see if our changes were saved like so:
    {
    "version": "0.2.0",
    "configurations": [{
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceRoot}\\server.js"
        },
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Training Script",
            "program": "${workspaceRoot}\\training-script.js",
            "runtimeArgs": [
                "--max-old-space-size=4096"
            ]
        }
    ]}
    
    9.

Linux (Ubuntu) (Ubuntu)

  1. Mở thiết bị đầu cuối và mở tệp .bashrc bằng Nano như vậy:.bashrc file using nano like so:

    node --max-old-space-size= path-to/fileName.js
    
    0

Các bước còn lại tương tự với các bước Mac từ phía trên, ngoại trừ chúng tôi rất có thể sẽ sử dụng

node --max-old-space-size= path-to/fileName.js
1 theo mặc định (trái ngược với ~/.zshrc). Vì vậy, những giá trị này sẽ cần phải được thay thế!

Liên kết đến tài liệu nodejs

Đã trả lời ngày 14 tháng 2 lúc 5:30Feb 14 at 5:30

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

JSON C11JSON C11JSON C11

10,5K6 Huy hiệu vàng76 Huy hiệu bạc63 Huy hiệu Đồng6 gold badges76 silver badges63 bronze badges

Trong trường hợp của tôi, tôi đã nâng cấp phiên bản Node.js lên mới nhất (phiên bản 12.8.0) và nó hoạt động như một sự quyến rũ.

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Aplet123

31.9K1 Huy hiệu vàng23 Huy hiệu bạc49 Huy hiệu đồng1 gold badge23 silver badges49 bronze badges

Đã trả lời ngày 12 tháng 6 năm 2020 lúc 8:06Jun 12, 2020 at 8:06

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

3

Sử dụng tùy chọn

node --max-old-space-size= path-to/fileName.js
2. Nó sẽ tập trung vào việc sử dụng ít RAM hơn.

Đã trả lời ngày 2 tháng 5 năm 2021 lúc 1:15May 2, 2021 at 1:15

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Vini Dalvinovini DalvinoVini Dalvino

4651 Huy hiệu vàng5 Huy hiệu bạc21 Huy hiệu đồng1 gold badge5 silver badges21 bronze badges

1

Tôi đã gặp lỗi này trên AWS đàn hồi Beanstalk, loại phiên bản nâng cấp từ T3.Micro (tầng miễn phí) lên T3.Small đã sửa lỗi

Đã trả lời ngày 9 tháng 12 năm 2021 lúc 9:31Dec 9, 2021 at 9:31

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Atazminatazminatazmin

3.6831 Huy hiệu vàng22 Huy hiệu bạc16 Huy hiệu đồng1 gold badge22 silver badges16 bronze badges

Nâng cấp nút lên phiên bản mới nhất. Tôi đã ở Node 6.6 với lỗi này và nâng cấp lên 8.9.4 và vấn đề đã biến mất.

Đã trả lời ngày 12 tháng 1 năm 2018 lúc 7:01Jan 12, 2018 at 7:01

Tôi đã trải qua vấn đề tương tự ngày hôm nay. Vấn đề đối với tôi là, tôi đã cố gắng nhập nhiều dữ liệu vào cơ sở dữ liệu trong dự án NextJS của mình.NextJS project.

Vì vậy, những gì tôi đã làm là, tôi đã cài đặt gói Win-Node-Env như thế này:

[md5:]  241613/241627 97.5%  
[md5:]  241614/241627 97.5%  
[md5:]  241625/241627 98.1%
Creating missing list... (79570 files missing)
Creating new files list... (241627 new files)

<--- Last few GCs --->

11629672 ms: Mark-sweep 1174.6 (1426.5) -> 1172.4 (1418.3) MB, 659.9 / 0 ms [allocation failure] [GC in old space requested].
11630371 ms: Mark-sweep 1172.4 (1418.3) -> 1172.4 (1411.3) MB, 698.9 / 0 ms [allocation failure] [GC in old space requested].
11631105 ms: Mark-sweep 1172.4 (1411.3) -> 1172.4 (1389.3) MB, 733.5 / 0 ms [last resort gc].
11631778 ms: Mark-sweep 1172.4 (1389.3) -> 1172.4 (1368.3) MB, 673.6 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3d1d329c9e59 
1: SparseJoinWithSeparatorJS(aka SparseJoinWithSeparatorJS) [native array.js:~84] [pc=0x3629ef689ad0] (this=0x3d1d32904189 ,w=0x2b690ce91071 ,L=241627,M=0x3d1d329b4a11 ,N=0x7c953bf4d49 )
2: Join(aka Join) [native array.js:143] [pc=0x3629ef616696] (this=0x3d1d32904189 
5

Bởi vì máy phát triển của tôi là Windows. Tôi đã cài đặt nó cục bộ hơn là toàn cầu. Bạn có thể cài đặt nó trên toàn cầu cũng như thế này:

node --max-old-space-size= path-to/fileName.js
3Windows. I installed it locally than globally. You can install it globally also like this:
node --max-old-space-size= path-to/fileName.js
3

Và sau đó trong tệp

node --max-old-space-size= path-to/fileName.js
4 của dự án NextJS của tôi, tôi đã thêm một tập lệnh khởi động khác như sau:

[md5:]  241613/241627 97.5%  
[md5:]  241614/241627 97.5%  
[md5:]  241625/241627 98.1%
Creating missing list... (79570 files missing)
Creating new files list... (241627 new files)

<--- Last few GCs --->

11629672 ms: Mark-sweep 1174.6 (1426.5) -> 1172.4 (1418.3) MB, 659.9 / 0 ms [allocation failure] [GC in old space requested].
11630371 ms: Mark-sweep 1172.4 (1418.3) -> 1172.4 (1411.3) MB, 698.9 / 0 ms [allocation failure] [GC in old space requested].
11631105 ms: Mark-sweep 1172.4 (1411.3) -> 1172.4 (1389.3) MB, 733.5 / 0 ms [last resort gc].
11631778 ms: Mark-sweep 1172.4 (1389.3) -> 1172.4 (1368.3) MB, 673.6 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3d1d329c9e59 
1: SparseJoinWithSeparatorJS(aka SparseJoinWithSeparatorJS) [native array.js:~84] [pc=0x3629ef689ad0] (this=0x3d1d32904189 ,w=0x2b690ce91071 ,L=241627,M=0x3d1d329b4a11 ,N=0x7c953bf4d49 )
2: Join(aka Join) [native array.js:143] [pc=0x3629ef616696] (this=0x3d1d32904189 
6

Ở đây, đang vượt qua tùy chọn nút, tức là. Đặt 8GB làm giới hạn. Vì vậy, tệp

node --max-old-space-size= path-to/fileName.js
4 của tôi có vẻ như thế này:

[md5:]  241613/241627 97.5%  
[md5:]  241614/241627 97.5%  
[md5:]  241625/241627 98.1%
Creating missing list... (79570 files missing)
Creating new files list... (241627 new files)

<--- Last few GCs --->

11629672 ms: Mark-sweep 1174.6 (1426.5) -> 1172.4 (1418.3) MB, 659.9 / 0 ms [allocation failure] [GC in old space requested].
11630371 ms: Mark-sweep 1172.4 (1418.3) -> 1172.4 (1411.3) MB, 698.9 / 0 ms [allocation failure] [GC in old space requested].
11631105 ms: Mark-sweep 1172.4 (1411.3) -> 1172.4 (1389.3) MB, 733.5 / 0 ms [last resort gc].
11631778 ms: Mark-sweep 1172.4 (1389.3) -> 1172.4 (1368.3) MB, 673.6 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3d1d329c9e59 
1: SparseJoinWithSeparatorJS(aka SparseJoinWithSeparatorJS) [native array.js:~84] [pc=0x3629ef689ad0] (this=0x3d1d32904189 ,w=0x2b690ce91071 ,L=241627,M=0x3d1d329b4a11 ,N=0x7c953bf4d49 )
2: Join(aka Join) [native array.js:143] [pc=0x3629ef616696] (this=0x3d1d32904189 
7

Và sau đó tôi chạy nó như thế này:

[md5:]  241613/241627 97.5%  
[md5:]  241614/241627 97.5%  
[md5:]  241625/241627 98.1%
Creating missing list... (79570 files missing)
Creating new files list... (241627 new files)

<--- Last few GCs --->

11629672 ms: Mark-sweep 1174.6 (1426.5) -> 1172.4 (1418.3) MB, 659.9 / 0 ms [allocation failure] [GC in old space requested].
11630371 ms: Mark-sweep 1172.4 (1418.3) -> 1172.4 (1411.3) MB, 698.9 / 0 ms [allocation failure] [GC in old space requested].
11631105 ms: Mark-sweep 1172.4 (1411.3) -> 1172.4 (1389.3) MB, 733.5 / 0 ms [last resort gc].
11631778 ms: Mark-sweep 1172.4 (1389.3) -> 1172.4 (1368.3) MB, 673.6 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3d1d329c9e59 
1: SparseJoinWithSeparatorJS(aka SparseJoinWithSeparatorJS) [native array.js:~84] [pc=0x3629ef689ad0] (this=0x3d1d32904189 ,w=0x2b690ce91071 ,L=241627,M=0x3d1d329b4a11 ,N=0x7c953bf4d49 )
2: Join(aka Join) [native array.js:143] [pc=0x3629ef616696] (this=0x3d1d32904189 
8

Đối với tôi, tôi chỉ phải đối mặt với vấn đề trên máy phát triển của mình (vì tôi đang thực hiện việc nhập dữ liệu lớn). Do đó giải pháp này. Được nghĩ để chia sẻ điều này vì nó có thể có ích cho người khác.

Đã trả lời ngày 8 tháng 3 lúc 21:44Mar 8 at 21:44

Tôi đã gặp vấn đề tương tự trong máy Windows và tôi nhận thấy rằng vì một số lý do, nó không hoạt động trong git bash, nhưng nó hoạt động trong shell power shell

Đã trả lời ngày 30 tháng 8 lúc 10:03Aug 30 at 10:03

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Chỉ trong trường hợp nó có thể giúp mọi người gặp sự cố này trong khi sử dụng các ứng dụng NodeJS tạo ra ghi nhật ký nặng, một đồng nghiệp đã giải quyết vấn đề này bằng cách đưa (các) đầu ra tiêu chuẩn vào một tệp.

Đã trả lời ngày 4 tháng 4 năm 2018 lúc 8:39Apr 4, 2018 at 8:39

Adrien Jolyadrien JolyAdrien Joly

4.8104 Huy hiệu vàng26 Huy hiệu bạc43 Huy hiệu Đồng4 gold badges26 silver badges43 bronze badges

Nếu bạn đang cố gắng khởi chạy không phải

#increase to 1gb
node --max-old-space-size=1024 index.js

#increase to 2gb
node --max-old-space-size=2048 index.js 

#increase to 3gb
node --max-old-space-size=3072 index.js

#increase to 4gb
node --max-old-space-size=4096 index.js

#increase to 5gb
node --max-old-space-size=5120 index.js

#increase to 6gb
node --max-old-space-size=6144 index.js

#increase to 7gb
node --max-old-space-size=7168 index.js

#increase to 8gb 
node --max-old-space-size=8192 index.js 

2, mà là một số mềm khác, ví dụ
node --max-old-space-size= path-to/fileName.js
7, bạn có thể sử dụng biến môi trường và gói
node --max-old-space-size= path-to/fileName.js
8:

[md5:]  241613/241627 97.5%  
[md5:]  241614/241627 97.5%  
[md5:]  241625/241627 98.1%
Creating missing list... (79570 files missing)
Creating new files list... (241627 new files)

<--- Last few GCs --->

11629672 ms: Mark-sweep 1174.6 (1426.5) -> 1172.4 (1418.3) MB, 659.9 / 0 ms [allocation failure] [GC in old space requested].
11630371 ms: Mark-sweep 1172.4 (1418.3) -> 1172.4 (1411.3) MB, 698.9 / 0 ms [allocation failure] [GC in old space requested].
11631105 ms: Mark-sweep 1172.4 (1411.3) -> 1172.4 (1389.3) MB, 733.5 / 0 ms [last resort gc].
11631778 ms: Mark-sweep 1172.4 (1389.3) -> 1172.4 (1368.3) MB, 673.6 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3d1d329c9e59 
1: SparseJoinWithSeparatorJS(aka SparseJoinWithSeparatorJS) [native array.js:~84] [pc=0x3629ef689ad0] (this=0x3d1d32904189 ,w=0x2b690ce91071 ,L=241627,M=0x3d1d329b4a11 ,N=0x7c953bf4d49 )
2: Join(aka Join) [native array.js:143] [pc=0x3629ef616696] (this=0x3d1d32904189 
9

Đã trả lời ngày 30 tháng 4 năm 2019 lúc 1:50Apr 30, 2019 at 1:50

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

PiterdenpiterdenPiterden

7554 Huy hiệu bạc14 Huy hiệu đồng4 silver badges14 bronze badges

Đối với gói dự án Angular, tôi đã thêm dòng dưới đây vào tệp pakage.json của tôi trong phần Scripts.added the below line to my pakage.json file in the scripts section.

 node --max-old-space-size=4096 yourFile.js
0

Bây giờ, để gói mã của mình, tôi sử dụng

node --max-old-space-size= path-to/fileName.js
9 thay vì
node --max-old-space-size=16000 scripts/build.js
0

hi vọng điêu nay co ich!

Đã trả lời ngày 4 tháng 10 năm 2019 lúc 16:00Oct 4, 2019 at 16:00

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

rgantlargantlargantla

1.8808 huy hiệu bạc16 huy hiệu đồng8 silver badges16 bronze badges

Đối với

node --max-old-space-size=16000 scripts/build.js
1, đây là cách tôi đã sửa

Trong

node --max-old-space-size=16000 scripts/build.js
2, bên trong
node --max-old-space-size=16000 scripts/build.js
3 thẻ thêm cái này

 node --max-old-space-size=4096 yourFile.js
1

Bây giờ trong

node --max-old-space-size=16000 scripts/build.js
4 thay vì sử dụng
node --max-old-space-size=16000 scripts/build.js
5 chỉ sử dụng

 node --max-old-space-size=4096 yourFile.js
2

Nếu bạn muốn sử dụng cấu hình này cho

node --max-old-space-size=16000 scripts/build.js
6 chỉ cần xóa
node --max-old-space-size=16000 scripts/build.js
7 khỏi cả 3 nơi

Đã trả lời ngày 12 tháng 3 năm 2021 lúc 17:07Mar 12, 2021 at 17:07

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

R15R15R15

Huy hiệu vàng 11.6K1377 Huy hiệu bạc145 Huy hiệu đồng13 gold badges77 silver badges145 bronze badges

Nếu bất kỳ câu trả lời nào không hoạt động cho bạn, hãy kiểm tra nút đã cài đặt của bạn nếu nó tương thích (tức là 32 bit hoặc 64 bit) với hệ thống của bạn. Thông thường loại lỗi này xảy ra do các phiên bản nút và hệ điều hành không tương thích và thiết bị đầu cuối/hệ thống sẽ không cho bạn biết về điều đó nhưng sẽ giúp bạn thoát khỏi lỗi bộ nhớ.

Đã trả lời ngày 4 tháng 6 năm 2021 lúc 14:01Jun 4, 2021 at 14:01

Shoaib iqbalshoaib iqbalShoaib Iqbal

2.1504 huy hiệu vàng23 Huy hiệu bạc46 Huy hiệu đồng4 gold badges23 silver badges46 bronze badges

Trong trường hợp của tôi, tôi đã chạy

node --max-old-space-size=16000 scripts/build.js
8 trên phiên bản trước của nút, sau một ngày nào đó tôi đã nâng cấp phiên bản nút và RAM
node --max-old-space-size=16000 scripts/build.js
8 cho một vài mô -đun. Sau đó, tôi đã nhận được lỗi này. Để khắc phục sự cố này, tôi đã xóa thư mục node_module khỏi mỗi dự án và chạy lại
node --max-old-space-size=16000 scripts/build.js
8.

Hy vọng điều này có thể khắc phục vấn đề.

Lưu ý: Điều này đã xảy ra trên máy cục bộ của tôi và nó chỉ được sửa trên máy cục bộ.

Đã trả lời ngày 2 tháng 4 năm 2019 lúc 7:16Apr 2, 2019 at 7:16

GampeshgampeshGampesh

3.7062 huy hiệu vàng11 Huy hiệu bạc8 Huy hiệu đồng2 gold badges11 silver badges8 bronze badges

Nếu bạn có bộ nhớ hoặc RAM giới hạn, thì hãy tìm lệnh sau.

ng phục vụ-nguồn-map = false

Nó sẽ có thể khởi chạy ứng dụng. Ví dụ của tôi, nó cần RAM 16GB. Nhưng tôi có thể chạy với RAM 8GB.

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Dharman ♦

Phù hiệu vàng 28K2121 gold badges75 silver badges127 bronze badges

Đã trả lời ngày 8 tháng 6 năm 2021 lúc 16:18Jun 8, 2021 at 16:18

Hướng dẫn which of the following is the correct approach to solve the process out of memory exception error in nodejs? - Cách tiếp cận nào sau đây là đúng để giải quyết lỗi ngoại lệ quá trình hết bộ nhớ trong nodejs?

Làm cách nào để giải quyết vấn đề rò rỉ bộ nhớ trong Node JS?

Một cách nhanh chóng để sửa nút. Rò rỉ bộ nhớ JS trong thời gian ngắn là khởi động lại ứng dụng. Đảm bảo làm điều này trước và sau đó dành thời gian để tìm kiếm nguyên nhân gốc rễ của rò rỉ bộ nhớ ...
Giám sát Sematext ..
Phòng khám. JS ..
Prometheus..
Giám sát trạng thái rõ ràng ..

Làm thế nào để bạn khắc phục lỗi nghiêm trọng đạt được phân bổ giới hạn heap thất bại heap ra khỏi bộ nhớ?

Cách khắc phục lỗi gây tử vong: C-Compacts không hiệu quả gần phân bổ giới hạn heap không thành công-JavaScript heap ra khỏi bộ nhớ ?..
Giải pháp 1 - Cài đặt phiên bản nút mới nhất.....
Giải pháp 2 - Tăng kích thước bộ nhớ bằng cách sử dụng xuất khẩu.....
Giải pháp 3 - Đặt bộ nhớ qua Node_options ..

Lỗi enoent trong nodejs là gì?

Các en enoent có thể xuất hiện do một số tệp bị thiếu hoặc sử dụng đường dẫn tương đối có thể được giải quyết bằng cách tạo cấu trúc thư mục dự kiến hoặc sử dụng đường dẫn tuyệt đối, tương ứng.Ngoài ra còn có nhiều lý do khác để nhận lỗi này.missing files or usage of the relative path that can be solved by creating an expected directory structure or using an absolute path, respectively. There are also many other reasons for getting this error.

Làm thế nào để bạn xử lý các lỗi nghiêm trọng trong nút JS?

Làm thế nào để bạn xử lý lỗi trong nút ...
Sử dụng lỗi tùy chỉnh để xử lý các lỗi hoạt động.....
Sử dụng một phần mềm trung gian.....
Khởi động lại ứng dụng của bạn một cách duyên dáng để xử lý các lỗi của lập trình viên.....
Bắt tất cả các trường hợp ngoại lệ.....
Bắt tất cả các lời hứa không được xử lý.....
Sử dụng một vị trí tập trung cho nhật ký và cảnh báo lỗi ..