# System.util.retarget heap space errors

**URL:** <https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871>\
**Category:** Ignition\
**Created:** [December 7, 2023, 11:19pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871 "2023-12-07T23:19:45Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [December 7, 2023, 11:19pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/1 "2023-12-07T23:19:45Z")

</div>

We have dozens of projects of various sizes, and a single Client project as an entry point. On login to the entry point Client project we have a startup script that determines which project and gateway to retarget to. For some time now, we have seen OutOfMemory heap space errors when retargeting with large projects. We also tried a traditional load balancer, with the same results. Eventually we just had to ignore our largest projects from the retargeting to keep things stable. We are now seeing issues after retargeting with smaller projects, but that have more memory intensive tasks. All of our projects are set to the maximum client memory, but it almost seems like that setting is not honored after retargeting since we are getting OutOfMemory errors when the task manager is only showing a few hundred MB of memory usage for the client which is well below the 4096 set. All clients are using the bundled JRE.

Does anyone know if the system.util.retarget preserves project settings like Client Memory or has anyone else run into this issue?

---

<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:** [December 7, 2023, 11:41pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/2 "2023-12-07T23:41:14Z")

</div>

> [@salbrechtsen](#):
>
> system.util.retarget preserves project settings like Client Memory

It's definitely supposed to, yes. And each client launch should be a fresh start, basically, so this is pretty weird. I'd recommend you engage with our support department for a proper investigation.

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [December 8, 2023, 1:26am UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/3 "2023-12-08T01:26:24Z")

</div>

What Ignition version are you on? I had an issue where system.util.retarget appeared to be leaking memory on 8.1.5. Support recommended I update to 8.1.13 and the issue went away. I think 8.1.13 was the newest version at the time, so it may have been fixed somewhere between those two versions.

Some anecdata I collected at that time using two minimal projects that only had one window. Each window contained only one button retargeting to each other project:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/f/ef88462d4e9cbf6ebf13676147848155fda3a519.png)

It was support ticket #36649 if that's relevant to anyone at IA.

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [December 8, 2023, 4:15pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/4 "2023-12-08T16:15:49Z")

</div>

I should clarify, we have zero issues retargeting to the same gateway. Its only when retargeting to another gateway that we see heap space issues.

I will do some more testing and likely reach out to support next week.

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [December 8, 2023, 4:17pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/5 "2023-12-08T16:17:04Z")

</div>

We are still on 7.9.13 for this part of our system. I do feel like i've seen memory leaks after retargeting as well, but haven't looked into it much.

---

<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:** [December 8, 2023, 4:30pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/6 "2023-12-08T16:30:31Z")

</div>

> [@salbrechtsen](#):
>
> We are still on 7.9.13 for this part of our system.

😬

All bets are off, then. I know for a _fact_ we've fixed a bunch of memory leaks since then, and I'm not sure that my statement about retargeting obeying memory settings even applies that far back.

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [December 8, 2023, 4:42pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/7 "2023-12-08T16:42:41Z")

</div>

At the least we need to get these upgraded to the latest 7 version, 8 is almost out of the picture right now due to the size of our system.

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [December 8, 2023, 4:48pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/8 "2023-12-08T16:48:45Z")

</div>

@paul-griffith I found this in the 7.9.18 notes... Any chance you could check if this fix applied to retargeting as well?

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/7/0724dc82dea75dfda6ef5c0f04e910df29e04fc2.png)

---

<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:** [December 8, 2023, 4:50pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/9 "2023-12-08T16:50:52Z")

</div>

> [@salbrechtsen](#):
>
> Any chance you could check if this fix applied to retargeting as well?

That particular fix is only for client launches from the designer, unfortunately; just confirmed.

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [December 8, 2023, 4:53pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/10 "2023-12-08T16:53:05Z")

</div>

Thank you for checking. We will get these gateways upgraded and go from there.

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [December 8, 2023, 5:16pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/11 "2023-12-08T17:16:15Z")

</div>

Do you know of a way to view either in logging or a script call what the current heap size is in a running client?

---

<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:** [December 8, 2023, 5:20pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/12 "2023-12-08T17:20:21Z")

</div>

An easy check would be `system.util.getProperty("javaws.sr.memory.max")`. This won't necessarily be accurate, but will tell you what Ignition is _trying_ to set the value to, if anything.

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [December 8, 2023, 5:22pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/13 "2023-12-08T17:22:07Z")

</div>

Thank you, thats very helpful. I'm assuming there is no way to set this with scripting?

In looking at the memory trend in my gateway retargeted client I can see the garbage collection happening right at 256MB, which I believe is the defaut limit.

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [December 8, 2023, 5:39pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/14 "2023-12-08T17:39:40Z")

</div>

An easier way is to go to the client list on the gateway. Here is the same project, on the same gateway. The first one has the max memory, and was not retargeted from another gateway  
 ![Screenshot 2023-12-08 at 10.37.09 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/c/dc42f0bc570df1f0cc689503709538440e3b3305.png)  
The second was retargeted from another gateway  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/6/4623ee92e3b4fbad6b2b11e82acae68f78806497.png)

So to me this points to a bug in ignition, closely related to the designer bug... When retargeting to another gateway, the client memory is reset to the 256MB default.

If IA is not going to fix this in 7 any sort of direction you could point me in to set this in scripting would be helpful. We do have a custom scripting module, so if there is an SDK method that would work.

I realize this is getting a bit deep and if you don't want to spend time with this I will call support next week.

---

<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:** [December 8, 2023, 5:55pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/15 "2023-12-08T17:55:27Z")

</div>

You can't reallocate the heap of an already extant Java process.

I don't really know what's going wrong.

Looking through the history, in 7.9. **6** we fixed a bug (treated as critical) where retargeting multiple times would "lose" the memory settings of the initial client launch, but memory setting should have been obeyed before and after that.

Oh... are you using the native client launchers, or JNLP? Can you isolate the 'not enough memory' issue to specific client computers? You might need to clear the Java cache on those computers (_if_ you're using JNLP, and _if_ you can confirm it only happens on certain computers).

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [December 8, 2023, 7:46pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/16 "2023-12-08T19:46:34Z")

</div>

Thats what I thought...

Yep, native client launcher with the bundled JDK. Happens regardless of machine, and regardless of clearing cache.

I can easily recreate the memory being reset to 256 by having a client on gatewayA retarget to the same or a different project on gatewayB in a client startup script. Both projects are set to 4096 memory. Retargeting to the same gateway, different project also with 4096 works properly.

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [December 13, 2023, 4:24pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/17 "2023-12-13T16:24:55Z")

</div>

We upgraded all gateways to 7.9.21 and still see the same issue. I'll reach out to support and try to see if we can figure out a solution with a custom module or something... Would be great if this could be patched but I realize supporting 7 is not a high priority.

---

<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 13, 2023, 4:28pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/18 "2023-12-13T16:28:32Z")

</div>

> [@salbrechtsen](#):
>
> supporting 7 is not a high priority.

Um. Six months away from complete abandonment. 🤷‍♂️

You won't get any patches. (Those ended 1½ years ago.) You should upgrade to 8.1, and get your support in order for 8.3 following soon.

---

<div class="post-metadata">

**Author:** ![salbrechtsen](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/salbrechtsen/32/18660_2.png) [@salbrechtsen](https://forum.inductiveautomation.com/u/salbrechtsen)\
**Post date:** [December 13, 2023, 4:37pm UTC](https://forum.inductiveautomation.com/t/system-util-retarget-heap-space-errors/82871/19 "2023-12-13T16:37:31Z")

</div>

Yes, we are well aware. We've been working on the upgrade to 8 for quite some time, the scale of our system makes the move complicated.
