# Can the memory limit set in JS\_NewContext be increased after the context is created?

**URL:** <https://discourse.mozilla.org/t/can-the-memory-limit-set-in-js-newcontext-be-increased-after-the-context-is-created/121022>\
**Category:** SpiderMonkey\
**Created:** [July 11, 2023, 10:37am UTC](https://discourse.mozilla.org/t/can-the-memory-limit-set-in-js-newcontext-be-increased-after-the-context-is-created/121022 "2023-07-11T10:37:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MilesT](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/milest/32/71131_2.png) [@MilesT](https://discourse.mozilla.org/u/MilesT)\
**Post date:** [July 11, 2023, 10:37am UTC](https://discourse.mozilla.org/t/can-the-memory-limit-set-in-js-newcontext-be-increased-after-the-context-is-created/121022/1 "2023-07-11T10:37:46Z")

</div>

Hi,  
I embed Spidermonkey in our software to give a JavaScript scripting ability.  
Some of the users of the software can create scripts that make millions of GCthings.  
Currently I allow the memory limit passed to JS\_NewContext to be changed **before** a script is run. However, if the size is too small, scripts can fail for users when they create these huge numbers of GCthings.  
I’ve always thought that this is a fixed limit for GC memory and cannot be changed once created, but is that the case?  
Is there any way to increase this size after the context has been created?  
I know that I can see how much GC memory is currently being used with JS::CollectRuntimeStats, so would it possible to allocate more memory if this got to 90% of the limit (as an example) and garbage collecting didn’t help?  
Does anybody have any idea if this is possible?  
Many thanks

---

<div class="post-metadata">

**Author:** ![MilesT](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/milest/32/71131_2.png) [@MilesT](https://discourse.mozilla.org/u/MilesT)\
**Post date:** [August 1, 2023, 12:32pm UTC](https://discourse.mozilla.org/t/can-the-memory-limit-set-in-js-newcontext-be-increased-after-the-context-is-created/121022/2 "2023-08-01T12:32:42Z")

</div>

From the lack of replies, I’m guessing that this isn’t possible (or perhaps something that isn’t obvious) ☹

If anybody does have any idea if it’s possible then please let me know. It would be very useful to know.
