GitbookIO / hunspell-spellchecker

Parse and use Hunspell dictionaries in Javascript
Apache License 2.0
77 stars 17 forks source link

JavaScript heap out of memory #26

Open shakhrillodev opened 8 months ago

shakhrillodev commented 8 months ago

I am getting the following error when trying to run my script which checks spelling for uzbek language:

<--- Last few GCs --->

[8592:0000018FE4796560] 53807 ms: Mark-sweep (reduce) 1754.5 (1828.9) -> 1754.5 (1797.4) MB, 3231.4 / 0.0 ms (average mu = 0.200, current mu = 0.000) last resort; GC in old space requested
[8592:0000018FE4796560] 57269 ms: Mark-sweep (reduce) 1754.5 (1797.4) -> 1754.5 (1797.1) MB, 3461.7 / 0.0 ms (average mu = 0.107, current mu = 0.000) last resort; GC in old space requested

<--- JS stacktrace --->

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory 1: 00007FF6FDB2D51F node_api_throw_syntax_error+175743 2: 00007FF6FDAB2E66 v8::internal::wasm::WasmCode::safepoint_table_offset+59654 3: 00007FF6FDAB4B72 v8::internal::wasm::WasmCode::safepoint_table_offset+67090 4: 00007FF6FE55AAB4 v8::Isolate::ReportExternalAllocationLimitReached+116 5: 00007FF6FE545E12 v8::Isolate::Exit+674 6: 00007FF6FE3DC8CE v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath+4030 7: 00007FF6FE3E42BA v8::internal::Factory::AllocateRaw+810 8: 00007FF6FE3FABDA v8::internal::FactoryBase::NewFixedArrayWithFiller+90 9: 00007FF6FE3FAEC3 v8::internal::FactoryBase::NewFixedArrayWithMap+35 10: 00007FF6FE1C20B6 v8::internal::HashTable<v8::internal::NameDictionary,v8::internal::NameDictionaryShape>::EnsureCapacity+246 11: 00007FF6FE1C90AD v8::internal::BaseNameDictionary<v8::internal::NameDictionary,v8::internal::NameDictionaryShape>::Add+109 12: 00007FF6FE0D2506 v8::internal::Runtime::GetObjectProperty+982 13: 00007FF6FE5F8051 v8::internal::SetupI

There are about 20000 lines in aff file and100000 lines in dic file. What can i do to fix that error. I even tried node --max-old-space-size=4096 .\script.js . But it is freezing without any output

Here is my code file: var fs = require('fs'); var Spellchecker = require("hunspell-spellchecker");

var spellchecker = new Spellchecker();

var DICT = spellchecker.parse({ aff: fs.readFileSync("./assets/uz/uz.aff"), dic: fs.readFileSync("./assets/uz/uz.dic") });

spellchecker.use(DICT); var isRight = spellchecker.check("tll"); console.log(isRight)