# Memory Usage, Gateway crash, JVM hung up

**URL:** <https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [June 29, 2023, 4:13pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722 "2023-06-29T16:13:04Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 29, 2023, 4:13pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/1 "2023-06-29T16:13:04Z")

</div>

Looking for some pointers or resources to turn to about this. We had a gateway crash and reboot.

From wrapper.log

```auto
STATUS | wrapper | 2023/06/29 15:18:42 | JVM appears hung: Timed out waiting for signal from JVM. Restarting JVM.
STATUS | wrapper | 2023/06/29 15:18:43 | JVM exited after being requested to terminate.
STATUS | wrapper | 2023/06/29 15:18:48 | Reloading Wrapper configuration...
STATUS | wrapper | 2023/06/29 15:18:48 | Launching a JVM...
```

This happened at the exact time I was executing a very large named query so I think our database got hung up on it and everything that came after also got hung up.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/b/1b15f431da03cb61b2a0bf6b9281c95de8f748dd.png)

What is concerning is I went over the 2 GB allotted. Is this a resource issue? Should I increase the memory allotted for Ignition? Should I move the named query to a stored procedure and execute it on the SQL database?

Any advice is much appreciated.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [June 29, 2023, 4:17pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/2 "2023-06-29T16:17:10Z")

</div>

I don't necessarily see the connection from the named query to the logs you posted here outside of the sequence of events you describe but outside of that I would say 2 gigs is very tiny for Ignition, especially if you have perspective projects. Can't say for sure from your post and logs, but I would not be surprised in the slightest if you ended having resource issues with that setup. I would add more for sure if you can, not even knowing anything else about what you have going on.

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 29, 2023, 4:21pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/3 "2023-06-29T16:21:09Z")

</div>

The named query takes place almost exactly at the time of the reboot shown in the graph as an empty space. The second spike was me trying to execute it again but cancelling sooner.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [June 29, 2023, 4:22pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/4 "2023-06-29T16:22:07Z")

</div>

Is it a select query with a lot of rows?

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 29, 2023, 4:24pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/5 "2023-06-29T16:24:15Z")

</div>

Before I limited the query to 10,000 rows it was everything in the table ( so yes it was).

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [June 29, 2023, 4:25pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/6 "2023-06-29T16:25:35Z")

</div>

Oh yea that tracks then imo. I think your analysis is probably correct. If this isn't a prod environment, I bet if you tested it (without limit) and ran the NQ again you could cause a gateway crash at will.

---

<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:** [June 29, 2023, 5:16pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/7 "2023-06-29T17:16:31Z")

</div>

Just to be pedantic/as clear as possible...

The snippet of logs you posted at the beginning doesn't actually mean the gateway wasn't responsive. It probably was struggling under GC load, which caused it to _appear_ unresponsive to the service wrapper. However, you can increase that timeout to make the wrapper less aggressive. In particular, the fact that the JVM exited cleanly after the wrapper asked it to means that your gateway was probably still running (just struggling) and would have eventually completed this query.

2gB is definitely under-provisioned, though.

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 29, 2023, 5:17pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/8 "2023-06-29T17:17:48Z")

</div>

I opened an official ticket and submitted the wrapper.log.

What would be a good amount of memory? 4GB?

---

<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:** [June 29, 2023, 5:18pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/9 "2023-06-29T17:18:32Z")

</div>

If this is the first time you've noticed issues, then 4gB is a reasonable place to start. Impossible to give a definitive answer of how much is enough without knowing all the details of your system.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [June 29, 2023, 5:18pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/10 "2023-06-29T17:18:46Z")

</div>

That's a very hard question to answer in a vacuum but for new projects I like to start with 8 GB when possible and change from there as needed.

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 29, 2023, 5:20pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/11 "2023-06-29T17:20:37Z")

</div>

The system is a week old and just today we added about 58 vision clients with very tiny functionality (4 buttons that run a script). And then we have 5 perspective sessions open currently.

---

<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:** [June 29, 2023, 5:24pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/12 "2023-06-29T17:24:15Z")

</div>

> [@bmeyers](#):
>
> And then we have 5 perspective sessions open currently.

Except for extreme queries, Vision is a pretty light gateway load. Perspective, not so much. I'd make sure the server had a couple GB for every Perspective client that can do more than trivial trends, and plenty of cores.

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 29, 2023, 5:28pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/13 "2023-06-29T17:28:27Z")

</div>

That seems extreme @pturmel. If I end up with 50 perspective clients are you recommending 50 GB memory?

---

<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:** [June 29, 2023, 5:32pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/14 "2023-06-29T17:32:19Z")

</div>

Depends on what you allow those clients to do, but yes.

I recommend you test **thoroughly**. I strongly recommend frontend/backend split setups for Perspective when there's more than one non-trivial client session expected. And sometimes even then.

Bogging down Perspective can disrupt your drivers and historization and any supervisory control in SFCs or timer events. If you are sizing a system for Perspective using your experience with Vision, you are screwing up.

Just think about how much RAM you give your Vision clients--add about that much on your gateway for every Perspective client, for similar activity.

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 29, 2023, 5:36pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/15 "2023-06-29T17:36:20Z")

</div>

Heh... well the system is in production now so building the plane while I fly I guess.

I am fairly confident my perspective clients are all trivial (except for the larger queries).

For reference the gateway is executing 0.4 queries per minute and I was careful to only trigger queries when necessary.

---

<div class="post-metadata">

**Author:** ![bmeyers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bmeyers/32/37453_2.png) [@bmeyers](https://forum.inductiveautomation.com/u/bmeyers)\
**Post date:** [June 29, 2023, 5:57pm UTC](https://forum.inductiveautomation.com/t/memory-usage-gateway-crash-jvm-hung-up/75722/16 "2023-06-29T17:57:10Z")

</div>

Final word from support ticket.

> [@](#):
>
> Based on the information so far what I think happened is that when you tried to run that large query it locked up the internal database of Ignition because it was trying to return a lot of points/rows and the JVM got hung which got terminated later. That is why the Gateway shut down. Limiting it to 1000 would ease the stress of large query returns on the Gateway and shouldn't shutdown again.
