FATAL ERROR: Reached heap limit Allocation failed – JavaScript heap out of memory Ec2 nodejs pm2

I am using ec2 machine and running nodejs application with pm2 and i am facing this issue

0|backend  | <--- Last few GCs --->
0|backend  |
0|backend  | [432704:0x7034870]  3263111 ms: Mark-sweep (reduce) 1918.1 (1953.3) -> 1917.7 (1954.0) MB, 801.2 / 0.0 ms  (+ 295.2 ms in 86 steps since start of marking, biggest step 22.1 ms, walltime since start of marking 1334 ms) (average mu = 0.347, current mu = 0.4[432704:0x7034870]  3264816 ms: Mark-sweep (reduce) 1918.7 (1954.0) -> 1917.9 (1954.5) MB, 1697.6 / 0.0 ms  (average mu = 0.190, current mu = 0.004) allocation failure; scavenge might not succeed
0|backend  |
0|backend  |
0|backend  | <--- JS stacktrace --->
0|backend  |
0|backend  | FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
0|backend  |  1: 0xb95be0 node::Abort() [node /home/ubuntu/project/backend/dist/main.js]
0|backend  |  2: 0xa9a7f8  [node /home/ubuntu/project/backend/dist/main.js]
0|backend  |  3: 0xd6f5b0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node /home/ubuntu/project/backend/dist/main.js]
0|backend  |  4: 0xd6f957 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node /home/ubuntu/project/backend/dist/main.js]
0|backend  |  5: 0xf4ceb5  [node /home/ubuntu/project/backend/dist/main.js]
0|backend  |  6: 0xf5f38d v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node /home/ubuntu/project/backend/dist/main.js]
0|backend  |  7: 0xf39a7e v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node /home/ubuntu/project/backend/dist/main.js]
0|backend  |  8: 0xf3ae47 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node /home/ubuntu/project/backend/dist/main.js]
0|backend  |  9: 0xf1c04a v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node /home/ubuntu/project/backend/dist/main.js]
0|backend  | 10: 0x12e139f v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node /home/ubuntu/project/backend/dist/main.js]
0|backend  | 11: 0x170e079  [node /home/ubuntu/project/backend/dist/main.js]
0|backend  | (node:432915) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.
0|backend  |
0|backend  | Please migrate your code to use AWS SDK for JavaScript (v3).
0|backend  | For more information, check the migration guide at https://a.co/7PzMCcy

on saying

pm2 monit

it is showing

enter image description here

is this total heap size ?

i have tried passing this as well

export NODE_OPTIONS=--max_old_space_size=1048;

and even

pm2 restart 0 --node-args="--max-old-space-size=1048"

so what can be the issue and how can i check my heap size assigned and used?