rocketmachine
@rocketmachine

Недостаточно памяти, как исправить?

Получаю вот такую ошибку:
<--- Last few GCs --->

[8388:0000017556D986B0]    47399 ms: Scavenge (reduce) 2047.1 (2082.9) -> 2046.6 (2083.2) MB, 24.0 / 0.0 ms  (average mu = 0.349, current mu = 0.300) allocation failure


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 00007FF70200815F v8::internal::CodeObjectRegistry::~CodeObjectRegistry+114079
 2: 00007FF701F954C6 DSA_meth_get_flags+65542
 3: 00007FF701F9637D node::OnFatalError+301
 4: 00007FF7028CBA0E v8::Isolate::ReportExternalAllocationLimitReached+94
 5: 00007FF7028B5FED v8::SharedArrayBuffer::Externalize+781
 6: 00007FF7027593BC v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1468
 7: 00007FF702766069 v8::internal::Heap::PublishPendingAllocations+1129
 8: 00007FF70276303A v8::internal::Heap::PageFlagsAreConsistent+2842
 9: 00007FF702755C99 v8::internal::Heap::CollectGarbage+2137
10: 00007FF702753E50 v8::internal::Heap::AllocateExternalBackingStore+2000
11: 00007FF7027789D6 v8::internal::Factory::NewFillerObject+214
12: 00007FF7024AAEA5 v8::internal::DateCache::Weekday+1797
13: 00007FF702959701 v8::internal::SetupIsolateDelegate::SetupHeap+494417
14: 0000017558E13CDA


Имею вот такой код:
async function checknamedirect(arg) {
    let check = await arg.startsWith('YT')
    if (check) {
        return true
    }
}

async function checkitems(limit, check, second_limit, megaitem, new_item, check_years, years, check_views, views) {
    let result = await Number(limit) <= Number(check) && Number(check) <= Number(second_limit) &&  megaitem == 'Y' + new_item && check_years <= years && check_views >= views
    if (result) {
        return true
    } else {
        return false
    }
}

getFiles('./folder/', function (err, files) { 
    fs.mkdir('result/' + limit[1] + ' do ' + second_limit[1], err => {
        console.log('Folder: '.green + limit[1] + ' do ' + second_limit[1] + ' was created');
    });
    fs.mkdir('result/' + limit[1] + ' do ' + second_limit[1] + '/Brand', err => {
        console.log('Folder: '.green + 'Brand was created');
    });
    fs.mkdir('result/' + limit[1] + ' do ' + second_limit[1] + '/NoBrand', err => {
        console.log('Folder:'.green +' NoBrand was created');
    });
    for (const megaitem of getDirectories('./folder/')) {
        if (checknamedirect(megaitem)) {
            for (const item of files) {
                let direct = path.dirname(item)
                const array = fs.readFileSync(item).toString().split("\n");
                for (const item of array) {
                    let check = item.match(/Account (.+) Subs: (\d+)/)
                    let check_years = item.match(/Created: .+\/.+\/(\d+)/)
                    let check_monet = item.match(/Monetized: (.+) Created/)
                    let check_views = item.match(/View: (\d+)/)    
                    let check_link = item.match(/Id: (.+) Title:/) 
                    if (check != null && second_limit != null && check_monet != null && check_views != null && check_years != null && check_link != null || check != undefined && second_limit != undefined && check_monet != undefined && check_views != undefined && check_years != undefined && check_link != undefined) {
                        let new_item = direct.match(/Y(.+)/)
                        checkitems(limit[1], check[2], second_limit[1], megaitem, new_item[1], check_years[1], years[1], check_views[1], views[1]).then( data => {
                            if (data) {
                                if (findWord('Brand', item)) {
                                    fska.copy('./folder/' + megaitem, './result/' + limit[1] + ' do ' + second_limit[1] + '/Brand/' + check_years[1] + '(Y) ' + check[2] + '(S) ' + check_monet[1] + '(M) '  + check_views[1] + '(V)' , err => { 
                                        console.log(megaitem + ' success copy! ' + ' BRAND'.red + ' ACCOUNT Subs: ' + check[2] + ' views: ' + check_views[1] + ' year: ' + check_years[1]);
                                        fs.writeFile('./result/' + limit[1] + ' do ' + second_limit[1] + '/Brand/' + check_years[1] + '(Y) ' + check[2] + '(S) ' + check_monet[1] + '(M) '  + check_views[1] + '(V)' + '/link.txt', check_link[1], 'utf8', (err) => { });
                                    });
                                } else {
                                    fska.copy('./folder/' + megaitem, './result/' + limit[1] + ' do ' + second_limit[1] + '/NoBrand/' + check_years[1] + '(Y) ' + check[2] + '(S) ' + check_monet[1] + '(M) '  + check_views[1] + '(V)' , err => { 
                                        console.log(megaitem + ' success copy!' + ' Default'.green +' ACCOUNT Subs: ' + check[2] + ' views: ' + check_views[1] + ' year: ' + check_years[1]);
                                        fs.writeFile('./result/' + limit[1] + ' do ' + second_limit[1] + '/NoBrand/' + check_years[1] + '(Y) ' + check[2] + '(S) ' + check_monet[1] + '(M) '  + check_views[1] + '(V)' + '/link.txt', check_link[1], 'utf8', (err) => { });
                                    });
                                }
                            }
                        })
                    }
                }
            }
        }
    }
});

Первый раз сталкиваюсь с такой ошибкой, не пойму из-за чего она, но появилась после async/await в коде, возможно не так использую, как исправить ?
  • Вопрос задан
  • 289 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы
28 нояб. 2024, в 13:31
30000 руб./за проект
28 нояб. 2024, в 13:22
1000 руб./за проект
28 нояб. 2024, в 13:00
70000 руб./за проект