# Bad Query Causing Increased Memory Usage

**URL:** <https://forum.inductiveautomation.com/t/bad-query-causing-increased-memory-usage/30144>\
**Category:** Ignition\
**Created:** [November 21, 2019, 3:48pm UTC](https://forum.inductiveautomation.com/t/bad-query-causing-increased-memory-usage/30144 "2019-11-21T15:48:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 21, 2019, 3:48pm UTC](https://forum.inductiveautomation.com/t/bad-query-causing-increased-memory-usage/30144/1 "2019-11-21T15:48:58Z")

</div>

v7.9.12 I ran a bad query with the database tool. It eventually timed out, Ignition’s memory usage went from 500-800mb to 1.2gb-2.9gb and it’s not going back down. It’s been about 15min since the bad query. Is this normal, or does something else need to be done?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 21, 2019, 3:51pm UTC](https://forum.inductiveautomation.com/t/bad-query-causing-increased-memory-usage/30144/2 "2019-11-21T15:51:51Z")

</div>

It’s only a problem if this memory has truly leaked and will never be recovered, but it may be too soon to tell.

If you have a tool like VisualVM installed on the gateway machine you can use it to request the JVM does a full GC.

You can also try running a script in gateway scope that invokes `System.gc()`.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 21, 2019, 4:25pm UTC](https://forum.inductiveautomation.com/t/bad-query-causing-increased-memory-usage/30144/3 "2019-11-21T16:25:13Z")

</div>

VisualVM says that it needs a Java JDK to run, so I probably won’t mess with it until later. The system.gc() errors out saying `object has no attribute 'gc'` while trying to run it as a gateway script in a project. I’m assuming a gateway restart would fix it, which is probably what I will have to do.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 21, 2019, 4:36pm UTC](https://forum.inductiveautomation.com/t/bad-query-causing-increased-memory-usage/30144/4 "2019-11-21T16:36:28Z")

</div>

You probably need to import System first:

```auto
from java.lang import System

System.gc()

```

Something like this…

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 21, 2019, 4:51pm UTC](https://forum.inductiveautomation.com/t/bad-query-causing-increased-memory-usage/30144/5 "2019-11-21T16:51:03Z")

</div>

That did run, but I didn’t see any impact yet. However, the memory looks like it is going down on its own before I used the system.gc(). it’s now dropping down to 250mb once it gets to about 1.5gb. Not where it should be, but it is improving. I will give it a little more time and see what happens. Appreciate the help.

**EDIT** I went ahead and restarted the gateway and all is well, I will note your suggestions in case I act like a bonehead again 🙂

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [November 21, 2019, 5:04pm UTC](https://forum.inductiveautomation.com/t/bad-query-causing-increased-memory-usage/30144/6 "2019-11-21T17:04:56Z")

</div>

> [@dkhayes117](#):
>
> it’s now dropping down to 250mb once it gets to about 1.5gb

Nothing to be concerned about here.

---

<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 21, 2019, 5:14pm UTC](https://forum.inductiveautomation.com/t/bad-query-causing-increased-memory-usage/30144/7 "2019-11-21T17:14:37Z")

</div>

Note that system != System.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 21, 2019, 5:40pm UTC](https://forum.inductiveautomation.com/t/bad-query-causing-increased-memory-usage/30144/8 "2019-11-21T17:40:44Z")

</div>

Yep I noticed that and used it as such. I guess I got a little lazy while typing. I did use `System.gc()` If anyone else comes across this post, it will be good to have that point clear. 👍
