2014年9月4日木曜日

Firefox の画像、JavaScript に関するメモリ使用量を抑える

Firefox のクラッシュ対策に H.264 / MP3 形式のサポートを無効にした。これにより、以前よりもかなり安定するようになった。しかし、残念ながら Google マップを利用したらクラッシュした。 (+_+)

そこで、メモリに関する設定を変更することにした。

ロケーションバーに about:config を入力し、以下の値を変更。

最初はページにある画像の読み込みに関する最大値を 50MB に抑える。

  • image.mem.max_decoded_image_kb: 51200

次に Javascript のメモリ消費量を 50MB に抑える。最後の値は、JavaScript が 32MB 消費したら、ガベージコレクションが動作するようにする。

  • javascript.options.mem.max: 51200
  • javascript.options.mem.high_water_mark: 32

How to Keep Firefox From Using Too Much Memory - Instant Fundas によると、

Reduce memory cache

… Web sites with a lot of large images can require very large amounts of memory. This problem can be mitigated by putting a cap to the amount of memory used by decoded images.

To do so, open the about:config page and search for image.mem.max_decoded_image_kb. By default, this is set to a very high value – 256000 or ~256 MB. Reduce this cache to something smaller, such as 50MB.

Similarly, memory assigned to Javascript is way too high. In webpages where there are lots of scripts doing lots of fancy things, memory footprint can increase quickly. To reduce memory consumption by Javascript, locate the parameter javascript.options.mem.max and change its value from -1 (automatic) to 51200 (50 MB).

Also find javascript.options.mem.high_water_mark, and set it to 30 from the default 128. This parameter tells the garbage collector to start running when javascript is using 30 MB of memory. Garbage collection releases memory back to the system.

ところで、上記の設定は、Firefox 31 で行なった。今、ちょうど Firefox 32 にアップデートした。

Mozilla、新しいキャッシュ機構と世代別GCを統合した「Firefox 32」を正式公開 - 窓の杜 によると、

「Firefox 32」では新しいHTTPキャッシュ機構(v2)が標準で有効化されたほか、世代別GCが統合された。ブラウザーのレンダリングが始まるまでの時間の短縮や、アプリケーションの応答性向上が期待できる。

一度、これまでの設定を元に戻して様子を見て、調子が悪ければ設定をまた戻すことにしよう。

さて、Firefox を再起動しようかな。