Fix: Google Chrome Ran Out Of Memory

Almost all of us use the internet on daily basis. And when it comes to internet browsing, Google Chrome is one of the top choice of users. But, even though Google Chrome is highly preferred by the users, you still might face some issues while using it. One of the issues that many people face while using Google Chrome is the “Aw Snap! Chrome ran out of memory” issue.

This issue is exactly what the error message tells you. Your Google Chrome runs out of memory. This is a problem because you will see this message despite having more than enough memory (RAM) on your computer. A lot of Chrome users face this issue out of nowhere. There are no warnings before this issue and there aren’t any specific hints that can help you predict the problem before happening. You might see this error on specific pages or it might be completely random. The error isn’t related to a specific website. This issue, if keeps happening, won’t let you browse normally and will keep showing this page on either random or specific websites.

The cause of issue is not clear. There are many reasons why this might be happening but it is clear that it’s a problem on the Google Chrome end, not on the website’s end. The issue might be caused by some extension or it might be because of a corrupted user profile or it might be because of the wrong Chrome version. Since there can be many reasons of this message, there are multiple solutions of this problem.

So, try to go through troubleshooting and if that doesn’t solve the problem then try each method listed below until the issue is resolved.

Troubleshooting

Method 1: Update to 64-bit

The first thing you should check is whether you have the 64 bit version of Google Chrome or not. This should be your priority especially if you think you have more than enough RAM for Google Chrome. The 64 bit version of Google Chrome is designed to use more memory so if your Chrome is giving this memory error even though you have a lot of memory available then this might be the issue.

If you aren’t sure whether you have a 32 bit or a 64 bit version then follow the steps given below

Once you are done, check whether the problem is still there or not.

Method 2: Using Task Manager

Sometimes killing the Google Chrome from the task manager and then restarting it solves the issue as well. This isn’t a permanent solution but more of a hack which you might have to do over and over. But if nothing else is working then this should come in handy.

These steps are to be performed while your Google Chrome is working and is showing the error.

Once it is closed, re-run the Google Chrome and you shouldn’t see the memory issue page anymore.

Method 3: Clear Cache

Clearing the cache of the browser might be a good option. It will solve the problem if there are any corrupted information stored in there that might be causing this issue.

To clear the cache of the browser, follow the steps given below

Now check whether the issue is gone or not.

Method 4: Disable Extensions

The problem might be caused by an extension as well. You can check whether the problem is because of an extension or not by disabling all the extensions. Once you disable all the extensions check whether the problem is still there. If the problem is gone then that means the problem was because of an extension. You can enable one extension at a time to check which one was causing the issue and then reinstall it.

To disable extensions on your Google Chrome, follow the steps given below

If the problem is gone then enable an extension by checking the Enabled box in front of it. Repeat this for all the extensions and once you find the extension that is causing the issue, delete it by clicking the dustbin box in front of it.

Method 5: Creating New User Profile

If the problem is caused by the information stored by the Google Chrome then changing the name of the default folder of Google Chrome might solve the issue for you. This can happen if your user profile is corrupted.

Follow the steps given below to change the name of your user profile folder

Now start Google Chrome again and check whether the issue still persists or not. Don’t worry about the folder, once you start Chrome again, it will recreate a new Default folder for you automatically.

Ошибка «Heap out of memory» в JavaScript возникает когда приложению недостаточно памяти. В этой статье мы разберемся как быстро исправить эту ошибку.

Как исправить «Heap out of memory» в JavaScript

Вы можете установить любое ограничение, но не используйте всю доступную память, иначе может произойти крэш системы.

Аналогичного эффекта можно добиться с помощью другого флага:

Изменение ограничения памяти для всей среды Node. js

«Heap out of memory» во время nmp install

Если во время установки пакетов с помощью npn или yarn у вас появляется эта ошибка, вы можете увеличить лимит памяти на время установки.

Что означает эта ошибка?

По умолчанию в Node. js установлен лимит памяти, который не позволяет программе занять слишком много памяти и уронить всю систему. Лимит отличается на разных версиях Node. js и архитектурах (32бита или 64бита).

Ограничения памяти на разных версиях Node. js

Эти значения не объявлены официально, но с помощью небольшой программы можно получить такие значения для 64 битной архитектуры.

Лимиты памяти на разных версиях Node. js

4GB памяти в куче будет достаточно для большинства случаев

Чтобы проверить лимит памяти вашей системы, создайте файл index. js и добавьте в него следующий код:

Как избежать недостатка памяти в Node. js

Увеличение лимита памяти поможет быстро исправить проблему, но этого может быть недостаточно. В следующий раз память системы может закончиться. В любом случае стоит выяснить источник проблемы.

Вот три альтернативных решения, которые позволят уменьшить потребление памяти.

Обработка данных по частям

Иногда нужно обработать большой набор данных. Например, вы пишите программу, которая принимает данные из CSV файла, очищает их и добавляет в БД (это называется ETL: извлечение, трансформация, загрузка).

Если в такой ситуации программе начинает не хватать памяти, попробуйте разделить данные на несколько частей.

Подробнее о том, как сделать это в MongoDB в этом ответе на StackOverflow.

Избегайте утечек памяти

В этой статье объясняется, как работает управление памятью в JavaScript, и как избежать большинства возможных утечек.

Её содержание сводится к тому, что большинство утечек, которые можно отследить, вызваны неудалёнными ссылками на объекты, которые больше не нужны. Это может случиться, когда вы забыли удалить interval, timer или чрезмерно используете глобальные переменные.

Профилирование

Профилирование помогает обнаружить утечки памяти. На фронтенде это можно сделать в Chrome в Инструментах разработчика во вкладке Memory.

В Node. js начиная с версии 6.3.0 также можно использовать Chrome для отладки использования памяти.

Во-первых, запустите приложение в режиме проверки:

Затем откройте страницу в Chrome, введите адрес chrome://inspect и нажмите на кнопку Open dedicated DevTools for Node.

После этого откроется окно, в котором вы сможете подключиться к вашему Node. js приложению.

Devtools Node. js

Перезапуск процессов

Допустим, ваша программа работает на компьютере с ограниченным объёмом памяти, например Raspberry Pi.

Мы будем использовать cluster и библиотеки node v8.

Cluster даёт возможность воспользоваться преимуществами многоядерных систем и запускать кластер из процессов Node. js.

V8 предоставляет API для конкретной версии V8, используемой в Node. js.

Давайте разделим программу на две сущности: master и worker.

Master будет перезапускать worker`ов в случае, если они перестанут работать из-за переполнения кучи. Worker`ы будут отвечать за основную логику (в нашем случае запускать тяжёлую функцию heavyHeapConsumer).

При первом запуске приложения создается worker и подписка на событие exit, при срабатывании которой создаётся новый worker, и событие логгируется.

total_heap_size — размер кучи, который можно увеличить.

heap_size_limit — максимально возможный размер кучи.

В коде worker`а устанавливается total_heap_size равный 85% от heap_size_limit. Затем worker каждую секунду проверяет не превышен ли лимит. Если лимит превышен, то процесс worker убивает себя.

Лимит (85%) и интервал проверки (1 секунда) нужно выбирать для каждого конкретного случая. Здесь функция heavyHeapConsumer увеличивает кучу каждые 100мс. Если в вашем варианте увеличение будет происходить каждые 10мс, то следует уменьшить лимит и увеличить интервал проверки.

Источники:

https://appuals. com/fix-google-chrome-ran-out-of-memory/

https://tproger. ru/translations/chto-delat-s-oshibkoj-heap-out-of-memory-v-javascript/

Понравилась статья? Поделиться с друзьями:
Добавить комментарий

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: