-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
RAG Knowledge JavaScript Heap Out of Memory #3664
Comments
Hello @suryanshkushwaha! Welcome to the elizaOS community. Thank you for opening your first issue; we appreciate your contribution. You are now an elizaOS contributor! |
@suryanshkushwaha try this. it worked for me.
|
that also worked for me. If you want to set a different memory size, you can adjust the number: |
افزایش حافظه: دستور: `node --max-old-space-size=8192 --loader ts-node/esm src/index.ts --characters=./characters/kaiadevbot.character.json 8192 به معنای ۸ گیگابایت حافظه است. مدیریت حافظه: استفاده کمتر از آرایهها و اشیاء بزرگ، استفاده از جریانهای داده (Streams)بهینهسازی دادههای غیرهمزمان، تقسیم دادهها به بخشهای کوچکتر |
@boolkeys did it in CLI with command: pnpm start --characters="characters/default.character.json" --max-old-space-size=8192 but it's not working for me :/ <--- Last few GCs ---> [35053:0x2f83c000] 27258 ms: Scavenge 1949.1 (1966.9) -> 1949.1 (1981.9) MB, pooled: 0 MB, 40.30 / 0.00 ms (average mu = 0.385, current mu = 0.245) allocation failure; <--- JS stacktrace ---> FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory ----- Native stack trace ----- 1: 0xe7e015 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node] |
No, just type it as a new command, not with pnpm start. Just type in CLI: export NODE_OPTIONS="--max-old-space-size=4096" |
@boolkeys cheers, javascript is not something I use often. That seems to have worked and was applied. However my host machine (vm) then crashed later after trying to run the character and apply rag knowledge. I have 6 gb allocated to it in total. Seems like there was too much memory consumption... |
برای بهینهسازی مصرف حافظه در Node.js، ابتدا باید بخشهای پرمصرف را شناسایی کنیم. سپس از روشهایی مانند استفاده از جریانها (Streams)، پردازش دادهها به بخشهای کوچکتر، و استفاده از Garbage Collection دستی برای کاهش مصرف حافظه بهره ببریم |
same issue even using --max-old-space-size=8192 and even 16384 which is 16GB of ram. Idts it is the issue of the less ram. |
تحلیل و بهینه سازی node --inspect --loader ts-node/esm src/index.ts --characters=./characters/default.character.json،از Garbage collectionبرای جمع اوری زباله و اینکه فواصل بین عملیات را افزایش دهد تا فرصت بیشتری برای پردازش داده ها باشد ،بررسی الگوریتم های بهینه تز تا حافظه کمتری استفاده شود ،پروفایلتان و مانیتورینگ و اینکه کدام بخش ها نیار به بهینه سازی دارد clinic.jsیاheapdumpو اینکه تقسیم فرایندها به بخش های کوچک تر یا اینکه کلا // جریان تبدیل برای پردازش خطی _transform(chunk, encoding, callback) { async function processFile(filePath) {
} catch (error) { // تنظیمات CLI program.parse(process.argv); |
Facing the same issue, using MAC M2 |
Some more info from testing: I loaded up 200+ .md files (each one is an article) and getting a lot of: Failed to read knowledge file {removed_actual_file_name}.md. Error details: Invalid array length I'm using --max-old-space-size=6144 and I tried to pnpm start my character about 20 times now. It brakes down every time, but it does process some new files in the meantime. |
@myconite Same issue for me, the export option seemed to work but now I am also getting the same error |
@myconite and @suryanshkushwaha, please do double check unnecessary line breaks and spaces. I was getting the same error due to slightly mismanaged prompt format. |
@t-phoenix no it's not that CLI command is fine. It seems to have something to do with the amount of files that need processing or the memory management of it? I ran the CLI command with the character and rag knowledge now about 40 times probably. Each time it does add some new articles to the database. Eventually it will probably go through them and finally load the character... until then I am still getting a lot of these: Failed to read knowledge file {removed_actual_file_name}.md. Error details: Invalid array length As can be seen here in the logs: [2025-02-27 03:21:24] INFO: Knowledge {removed_actual_file_name}.md unchanged, skipping |
Description
The application is crashing with a "JavaScript heap out of memory" error when processing knowledge/messages. The error occurs during runtime execution with a heap size of approximately 4GB.
To Reproduce
Error Details
Stack Trace
Key components in stack trace:
Technical Details
Proposed Solutions
Unaware
Additional Context
Error
The text was updated successfully, but these errors were encountered: