# Ignition Memory increasing after Scripting Restart

**URL:** <https://forum.inductiveautomation.com/t/ignition-memory-increasing-after-scripting-restart/66799>\
**Category:** Ignition\
**Created:** [November 22, 2022, 10:38am UTC](https://forum.inductiveautomation.com/t/ignition-memory-increasing-after-scripting-restart/66799 "2022-11-22T10:38:47Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![majad](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@majad](https://forum.inductiveautomation.com/u/majad)\
**Post date:** [November 22, 2022, 10:38am UTC](https://forum.inductiveautomation.com/t/ignition-memory-increasing-after-scripting-restart/66799/1 "2022-11-22T10:38:47Z")

</div>

Hello there,

i wrote some functions in a shared Script which are called from an UDTs valueChanged event. Now every time i save some Changes i made in my Script and the Scripting restarts because of that the Memory usage is grwoing a bit.  
After that the Memory performs normal but is generally on a higher level.  
What could cause such a behaviour and is there a way to 1. Bring down memory to the usual level and 2. Avoid this in the future?

Thanks for help

---

<div class="post-metadata">

**Author:** ![franklepkowski](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/franklepkowski/32/4808_2.png) [@franklepkowski](https://forum.inductiveautomation.com/u/franklepkowski)\
**Post date:** [November 22, 2022, 12:35pm UTC](https://forum.inductiveautomation.com/t/ignition-memory-increasing-after-scripting-restart/66799/2 "2022-11-22T12:35:07Z")

</div>

Hello. We have seen saves cause this exact issue. What version of Ignition are you running?

Frank

---

<div class="post-metadata">

**Author:** ![majad](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@majad](https://forum.inductiveautomation.com/u/majad)\
**Post date:** [November 22, 2022, 12:45pm UTC](https://forum.inductiveautomation.com/t/ignition-memory-increasing-after-scripting-restart/66799/3 "2022-11-22T12:45:38Z")

</div>

I am on Version 8.1.17

---

<div class="post-metadata">

**Author:** ![franklepkowski](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/franklepkowski/32/4808_2.png) [@franklepkowski](https://forum.inductiveautomation.com/u/franklepkowski)\
**Post date:** [November 22, 2022, 1:22pm UTC](https://forum.inductiveautomation.com/t/ignition-memory-increasing-after-scripting-restart/66799/4 "2022-11-22T13:22:35Z")

</div>

Can you upgrade to the latest stable release? I believe a fix was put into one of the newer releases to address this issue.

Frank

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 22, 2022, 1:34pm UTC](https://forum.inductiveautomation.com/t/ignition-memory-increasing-after-scripting-restart/66799/5 "2022-11-22T13:34:31Z")

</div>

If you are using `system.util.invokeAsynchronous` to launch long-lived threads, and you don't kill them off when the project is saved, then you are leaking the entire Jython interpreter infrastructure every time. Also applies to misuse of event scripts that do not complete quickly (infinite loops, or very long tasks).

There's no Ignition fix if this is what you are doing.

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [November 22, 2022, 1:39pm UTC](https://forum.inductiveautomation.com/t/ignition-memory-increasing-after-scripting-restart/66799/6 "2022-11-22T13:39:33Z")

</div>

There is an update coming in 8.1.23 that corrects for some orphaned objects that weren't getting cleaned up on project scripting restart. The growth here was very small though and manifested more when there were a lot of inherited projects. It is definitely worth taking a look at what @pturmel mentioned above...

---

<div class="post-metadata">

**Author:** ![majad](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@majad](https://forum.inductiveautomation.com/u/majad)\
**Post date:** [November 22, 2022, 1:41pm UTC](https://forum.inductiveautomation.com/t/ignition-memory-increasing-after-scripting-restart/66799/7 "2022-11-22T13:41:58Z")

</div>

Thank you, i will check if i can upgrade and see if this fixes my issue!

---

<div class="post-metadata">

**Author:** ![majad](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@majad](https://forum.inductiveautomation.com/u/majad)\
**Post date:** [November 22, 2022, 1:43pm UTC](https://forum.inductiveautomation.com/t/ignition-memory-increasing-after-scripting-restart/66799/8 "2022-11-22T13:43:25Z")

</div>

Thanks, I already looked into this and can't find anything what would cause something like this... But i will take a closer look

---

<div class="post-metadata">

**Author:** ![majad](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@majad](https://forum.inductiveautomation.com/u/majad)\
**Post date:** [November 22, 2022, 1:44pm UTC](https://forum.inductiveautomation.com/t/ignition-memory-increasing-after-scripting-restart/66799/9 "2022-11-22T13:44:19Z")

</div>

Yeah, the growth for every restart is very small but adds up over time..

---

<div class="post-metadata">

**Author:** ![majad](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@majad](https://forum.inductiveautomation.com/u/majad)\
**Post date:** [December 2, 2022, 9:46am UTC](https://forum.inductiveautomation.com/t/ignition-memory-increasing-after-scripting-restart/66799/10 "2022-12-02T09:46:11Z")

</div>

Okay. Again, thank you for your answer.  
After looking more deeper into some Scripting i found that the system.util.invokeAsynchronous is used.  
It is used in the Project library in a shared syript of my "Global" Project from which a few other projects inherit. Now i would like to close the thread if i restart my Scripting but don't quite know how I would do this right now.  
I know that system.util.invokeAsynchronous returns the executing thread also that the Gateway Event Update script runs every time i restart my Scripts. Now my idea would be that in the Gateway Event Update i test if my thread is still running and if so kill it off.  
How is it possible to safe the executing thread? How do i make sure that the thread i want to kill off is actually the one i called my function on? So in general, how would i kill off the thread when i save my project ?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 2, 2022, 10:18am UTC](https://forum.inductiveautomation.com/t/ignition-memory-increasing-after-scripting-restart/66799/11 "2022-12-02T10:18:33Z")

</div>

It isn’t safe to kill threads. Threads can and should be designed to be interruptible (checking for interrupt status and/or exceptions for graceful exit). If you didn’t do that, interrupt() may not work. If not, you will have to restart the gateway.

Start here:

> [@Managing multiple asynchronous threads](https://forum.inductiveautomation.com/t/managing-multiple-asynchronous-threads/37185):
>
> I've followed this post for monitoring a directory for file changes and I think I have created more than one watch service in different threads. How do I monitor, manage, and delete these threads?

Some other search results:

[https://forum.inductiveautomation.com/search?q=kill%20invokeAsynchronous](https://forum.inductiveautomation.com/search?q=kill%20invokeAsynchronous)

[https://forum.inductiveautomation.com/search?q=persistent%20thread%20leak](https://forum.inductiveautomation.com/search?q=persistent%20thread%20leak)
