# Can Firefox kill my background script if it's out of memory?

**URL:** <https://discourse.mozilla.org/t/can-firefox-kill-my-background-script-if-its-out-of-memory/25412>\
**Category:** Development\
**Created:** [February 9, 2018, 9:17pm UTC](https://discourse.mozilla.org/t/can-firefox-kill-my-background-script-if-its-out-of-memory/25412 "2018-02-09T21:17:31Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![rugkx](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/rugkx/32/19322_2.png) [@rugkx](https://discourse.mozilla.org/u/rugkx)\
**Post date:** [July 6, 2018, 5:43pm UTC](https://discourse.mozilla.org/t/can-firefox-kill-my-background-script-if-its-out-of-memory/25412/2 "2018-07-06T17:43:48Z")

</div>

According to this thread:

> [@How long are background scripts valid for?](https://discourse.mozilla.org/t/how-long-are-background-scripts-valid-for/10402):
>
> I am looking to add a feature to my web extension that will give the user a notification after x amount of times using my add-on, asking for them to rate my add-on. When the user clicks the button and is directed to the extension’s AMO page, I want the notification to be forever hidden. I will obviously need to use my background.js file to implement this. I was just curious how long the background.js file will keep variables active for before they are reset? I’ll be storing a variable in the ba…

…Chrome may kill them on low-memory, but Firefox (currently!) does not do so.  
So, to be good/future-proof, you should maybe still rather code it in a way that does not rely on having background pages always accessible.

Basically, I’d say storing multiple MB images in a background script is not really a good idea. Remember it stays in memory all the time (if it does, of course), so this can be a big waste of RAM.

---

_[View the full topic](https://discourse.mozilla.org/t/can-firefox-kill-my-background-script-if-its-out-of-memory/25412)._
