# There are questions about how perspective-worker is invoked

**URL:** <https://forum.inductiveautomation.com/t/there-are-questions-about-how-perspective-worker-is-invoked/86570>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [February 29, 2024, 5:08am UTC](https://forum.inductiveautomation.com/t/there-are-questions-about-how-perspective-worker-is-invoked/86570 "2024-02-29T05:08:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cj3687\_L](https://avatars.discourse-cdn.com/v4/letter/c/54ee81/32.png) [@cj3687\_L](https://forum.inductiveautomation.com/u/cj3687_L)\
**Post date:** [February 29, 2024, 5:08am UTC](https://forum.inductiveautomation.com/t/there-are-questions-about-how-perspective-worker-is-invoked/86570/1 "2024-02-29T05:08:41Z")

</div>

Now in my project, I have a thread called perspective-worker, and I don't know how it gets called, but it takes up a lot of resources and even causes my server to crash

 ![130116](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/5/751bcd5a4bff8994819bc076b2a19eb096f0a0c8.jpeg)

---

<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:** [February 29, 2024, 1:03pm UTC](https://forum.inductiveautomation.com/t/there-are-questions-about-how-perspective-worker-is-invoked/86570/2 "2024-02-29T13:03:06Z")

</div>

Perspective uses dynamic thread pools to handle bindings and events throughout its operations. You have to look at the stack trace to see what's going on, but you've cut it off. (Post text in a pre-formatted text block, not screenshots.)

But from the monitors locked, I'm guessing you have a runaway script. (Or a script tasked with something too complex for the amount of gateway RAM available--that will crash your gateway.)

Look for more details to share.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 29, 2024, 3:48pm UTC](https://forum.inductiveautomation.com/t/there-are-questions-about-how-perspective-worker-is-invoked/86570/3 "2024-02-29T15:48:25Z")

</div>

Note there are some configuration parameters you can use to cap or otherwise control the by default unbound thread pool for Perspective workers:

> **[Perspective Parameters | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/reference-pages/gateway-configuration-file-reference/perspective-parameters#threadpool-restrictions)**
>
> Session Caching

---

<div class="post-metadata">

**Author:** ![Sheng\_YD](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@Sheng\_YD](https://forum.inductiveautomation.com/u/Sheng_YD)\
**Post date:** [March 5, 2024, 4:00pm UTC](https://forum.inductiveautomation.com/t/there-are-questions-about-how-perspective-worker-is-invoked/86570/4 "2024-03-05T16:00:28Z")

</div>

Out of 4513 Perspective-worker threads, the number of threads ① is 724 and threads ② is 3700.  
What are these threads used for?  
①

 ![20240305-234717](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/6/16757b169a0cfd8c86b73f7aafe93d3b6e74bcc0.jpeg)  
[java.base@11.0.18/java.lang.Class.getDeclaredConstructors0(Native Method)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Class.html) [java.base@11.0.18/java.lang.Class.privateGetDeclaredConstructors(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Class.html) [java.base@11.0.18/java.lang.Class.getConstructor0(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Class.html) [java.base@11.0.18/java.lang.Class.getConstructor(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Class.html) [app//org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:251)](https://www.javadoc.io/static/org.python/jython-standalone/2.7.3/org/python/core/BytecodeLoader.html) app//org.python.compiler.LegacyCompiler$LazyLegacyBundle.loadCode(LegacyCompiler.java:43) [app//org.python.core.CompilerFacade.compile(CompilerFacade.java:33)](https://www.javadoc.io/static/org.python/jython-standalone/2.7.3/org/python/core/CompilerFacade.html) [app//org.python.core.Py.compile\_flags(Py.java:2218)](https://www.javadoc.io/static/org.python/jython-standalone/2.7.3/org/python/core/Py.html) [app//org.python.core.Py.compile\_flags(Py.java:2223)](https://www.javadoc.io/static/org.python/jython-standalone/2.7.3/org/python/core/Py.html) [app//org.python.core.Py.compile\_flags(Py.java:2253)](https://www.javadoc.io/static/org.python/jython-standalone/2.7.3/org/python/core/Py.html) [app//com.inductiveautomation.ignition.common.script.ScriptManager.compileFunction(ScriptManager.java:898)](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.32/com/inductiveautomation/ignition/common/script/ScriptManager.html) app//com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.compileFunctionSuper(ProjectScriptLifecycle.java:789) app//com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.getOrCreateDelegate(ProjectScriptLifecycle.java:888) app//com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.(ProjectScriptLifecycle.java:879) app//com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.compileFunction(ProjectScriptLifecycle.java:774) [app//com.inductiveautomation.ignition.common.script.ScriptManager.compileFunction(ScriptManager.java:881)](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.32/com/inductiveautomation/ignition/common/script/ScriptManager.html) com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.lambda$invoke$0(ScriptFunctionHelper.java:114) [com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper$$Lambda$7389/0x0000000802335c40.apply(Unknown Source)](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.32/com/inductiveautomation/perspective/gateway/script/ScriptFunctionHelper.html) [java.base@11.0.18/java.util.concurrent.atomic.AtomicReference.updateAndGet(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/atomic/AtomicReference.html) [com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:107)](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.32/com/inductiveautomation/perspective/gateway/script/ScriptFunctionHelper.html) [com.inductiveautomation.perspective.gateway.script.ScriptRunner.run(ScriptRunner.java:38)](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.32/com/inductiveautomation/perspective/gateway/script/ScriptRunner.html) [java.base@11.0.18/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/Executors.html) [java.base@11.0.18/java.util.concurrent.FutureTask.run(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/FutureTask.html) [java.base@11.0.18/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/ThreadPoolExecutor.html) [java.base@11.0.18/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/ThreadPoolExecutor.html) [com.inductiveautomation.perspective.gateway.threading.BlockingWork$BlockingWorkRunnable.run(BlockingWork.java:58)](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.32/com/inductiveautomation/perspective/gateway/threading/BlockingWork.html) [java.base@11.0.18/java.lang.Thread.run(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Thread.html)

②

 ![20240305-234555](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/3/737495c5dc598d907141815d57f6d7a8bb70dd5d.jpeg)  
[java.base@11.0.18/java.lang.ClassLoader.defineClass1(Native Method)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/ClassLoader.html) [java.base@11.0.18/java.lang.ClassLoader.defineClass(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/ClassLoader.html) [app//org.python.core.BytecodeLoader$Loader.loadClassFromBytes(BytecodeLoader.java:313)](https://www.javadoc.io/static/org.python/jython-standalone/2.7.3/org/python/core/BytecodeLoader.html) [app//org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:37)](https://www.javadoc.io/static/org.python/jython-standalone/2.7.3/org/python/core/BytecodeLoader.html) [app//org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:249)](https://www.javadoc.io/static/org.python/jython-standalone/2.7.3/org/python/core/BytecodeLoader.html) app//org.python.compiler.LegacyCompiler$LazyLegacyBundle.loadCode(LegacyCompiler.java:43) [app//org.python.core.CompilerFacade.compile(CompilerFacade.java:33)](https://www.javadoc.io/static/org.python/jython-standalone/2.7.3/org/python/core/CompilerFacade.html) [app//org.python.core.Py.compile\_flags(Py.java:2218)](https://www.javadoc.io/static/org.python/jython-standalone/2.7.3/org/python/core/Py.html) [app//org.python.core.Py.compile\_flags(Py.java:2223)](https://www.javadoc.io/static/org.python/jython-standalone/2.7.3/org/python/core/Py.html) [app//org.python.core.Py.compile\_flags(Py.java:2253)](https://www.javadoc.io/static/org.python/jython-standalone/2.7.3/org/python/core/Py.html) [app//com.inductiveautomation.ignition.common.script.ScriptManager.compileFunction(ScriptManager.java:898)](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.32/com/inductiveautomation/ignition/common/script/ScriptManager.html) app//com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.compileFunctionSuper(ProjectScriptLifecycle.java:789) app//com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.getOrCreateDelegate(ProjectScriptLifecycle.java:888) app//com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.(ProjectScriptLifecycle.java:879) app//com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$TrackingProjectScriptManager.compileFunction(ProjectScriptLifecycle.java:774) [app//com.inductiveautomation.ignition.common.script.ScriptManager.compileFunction(ScriptManager.java:881)](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.32/com/inductiveautomation/ignition/common/script/ScriptManager.html) com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.lambda$invoke$0(ScriptFunctionHelper.java:114) [com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper$$Lambda$7389/0x0000000802335c40.apply(Unknown Source)](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.32/com/inductiveautomation/perspective/gateway/script/ScriptFunctionHelper.html) [java.base@11.0.18/java.util.concurrent.atomic.AtomicReference.updateAndGet(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/atomic/AtomicReference.html) [com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:107)](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.32/com/inductiveautomation/perspective/gateway/script/ScriptFunctionHelper.html) [com.inductiveautomation.perspective.gateway.script.ScriptRunner.run(ScriptRunner.java:38)](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.32/com/inductiveautomation/perspective/gateway/script/ScriptRunner.html) [java.base@11.0.18/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/Executors.html) [java.base@11.0.18/java.util.concurrent.FutureTask.run(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/FutureTask.html) [java.base@11.0.18/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/ThreadPoolExecutor.html) [java.base@11.0.18/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/ThreadPoolExecutor.html) [com.inductiveautomation.perspective.gateway.threading.BlockingWork$BlockingWorkRunnable.run(BlockingWork.java:58)](https://files.inductiveautomation.com/sdk/javadoc/ignition81/8.1.32/com/inductiveautomation/perspective/gateway/threading/BlockingWork.html) [java.base@11.0.18/java.lang.Thread.run(Unknown Source)](https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Thread.html)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 5, 2024, 4:05pm UTC](https://forum.inductiveautomation.com/t/there-are-questions-about-how-perspective-worker-is-invoked/86570/5 "2024-03-05T16:05:38Z")

</div>

Both of those stacktraces are involved in compiling your Jython code to run it as a script. That _should_ be a relatively quick operation (on the order of milliseconds) and it _should_ be cached and only performed once per defined script. That you've apparently got thousands of threads doing the same _type_ of work suggests some pathological case that we've never encountered before. I'd strongly suggest contacting our support department.

---

<div class="post-metadata">

**Author:** ![Sheng\_YD](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@Sheng\_YD](https://forum.inductiveautomation.com/u/Sheng_YD)\
**Post date:** [March 5, 2024, 4:21pm UTC](https://forum.inductiveautomation.com/t/there-are-questions-about-how-perspective-worker-is-invoked/86570/6 "2024-03-05T16:21:06Z")

</div>

We observed that when the PLC is powered off and restarted, the number of threads increases to over 20,000 within 3 minutes, which causes the gateway to crash. More than 90% of these threads are Perspective workers. What tasks might these threads be processing? For example, scripts in the View or points bind to the PLC?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/f/8fb9675ff799ae30bd3e253922464c47adc1fa65.png)  
We attempted to address the issue by modifying the `-Dperspective.threadpool.perspective-worker.pool-size` setting to limit the number of threads. However, this did not solve the underlying problem, and we are unsure of what is triggering these threads.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 5, 2024, 4:26pm UTC](https://forum.inductiveautomation.com/t/there-are-questions-about-how-perspective-worker-is-invoked/86570/7 "2024-03-05T16:26:36Z")

</div>

> I'd strongly suggest contacting our support department.

Without scanning every stack trace in a thread dump _and_ having your project to compare to, it's literally impossible to say. I don't know, and can't tell you, if you've discovered a bug in Ignition, if you're doing something wrong, if your computer is cursed, or what. You need to provide more information _to someone who's getting paid to help you_. This forum isn't an official support venue.
