# Java Heap Space error giving scattered screen on clients

**URL:** <https://forum.inductiveautomation.com/t/java-heap-space-error-giving-scattered-screen-on-clients/45162>\
**Category:** Ignition\
**Created:** [April 1, 2021, 9:35am UTC](https://forum.inductiveautomation.com/t/java-heap-space-error-giving-scattered-screen-on-clients/45162 "2021-04-01T09:35:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neha.kabra](https://avatars.discourse-cdn.com/v4/letter/n/e36b37/32.png) [@Neha.kabra](https://forum.inductiveautomation.com/u/Neha.kabra)\
**Post date:** [April 1, 2021, 9:35am UTC](https://forum.inductiveautomation.com/t/java-heap-space-error-giving-scattered-screen-on-clients/45162/1 "2021-04-01T09:35:17Z")

</div>

Hello,

please help me with below issue which gives me Java Heap Space error on line10 in below mentioned code. That results to window loading issue & scattered screen with so many screen hang issue for running clients.

here i am posting code for above issue. That code written on client tag change script which runs frequently in a 1sec.

import time  
LTSTDescription = system.tag.read("[client]LineStationDetails.Value").value  
if newValue.value == 1:  
dispStr = system.tag.read("[client]Footer\_DisplayStr.Value").value # Push blank string here at Client tag  
newStr = system.tag.read("[client]Footer\_Marquee.Value").value # Push blank string here at client tag  
s1 = system.tag.read("[default]"+str(LTSTDescription)+"/Footer/Message\_FOOTER.Value").value  
s2 = system.tag.read("[default]"+str(LTSTDescription)+"/Footer/MessageMarquee.Value").value  
Sleeptime = 0.25  
dispStr1 = dispStr[1:] + s1[0:]  
newStr2 = newStr[1:] + s2[0:]  
system.tag.write("[client]Footer\_DisplayStr",dispStr1)  
system.tag.write("[client]Footer\_Marquee",newStr2)  
time.sleep(Sleeptime)

```
system.tag.write("[client]Footer_IsConcat",1)
system.tag.write("[client]Footer_Movement",0)

```

kindly reply on same.  
Thanks

---

<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:** [April 1, 2021, 11:36am UTC](https://forum.inductiveautomation.com/t/java-heap-space-error-giving-scattered-screen-on-clients/45162/2 "2021-04-01T11:36:12Z")

</div>

That suggests that your strings are growing without bounds. Also, you are using time.sleep. That is extremely unwise (can lead to lockups and crashes).

---

<div class="post-metadata">

**Author:** ![Neha.kabra](https://avatars.discourse-cdn.com/v4/letter/n/e36b37/32.png) [@Neha.kabra](https://forum.inductiveautomation.com/u/Neha.kabra)\
**Post date:** [April 1, 2021, 11:48am UTC](https://forum.inductiveautomation.com/t/java-heap-space-error-giving-scattered-screen-on-clients/45162/3 "2021-04-01T11:48:35Z")

</div>

OK thanks.

after removing time.sleep also giving same java heap space error.  
kindly, suggest modifications related to code that how to crop strings by growing without bounds.

That will really helpful in case of corrective code action against above code.

Thanks.

---

<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:** [April 1, 2021, 12:42pm UTC](https://forum.inductiveautomation.com/t/java-heap-space-error-giving-scattered-screen-on-clients/45162/4 "2021-04-01T12:42:49Z")

</div>

Where you are concatenating your strings, you are using unbounded slice notation (like so: `xx[1:]`). Put an end value in those slices appropriate to your use, `[1:50]` or `[1:200]` perhaps.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [April 2, 2021, 12:53am UTC](https://forum.inductiveautomation.com/t/java-heap-space-error-giving-scattered-screen-on-clients/45162/5 "2021-04-02T00:53:01Z")

</div>

If you wrap your code in three back ticks, the forum will keep your code formatting, e. G. :

```auto
import time
LTSTDescription = system.tag.read("[client]LineStationDetails.Value").value
if newValue.value == 1:
  dispStr = system.tag.read("[client]Footer_DisplayStr.Value").value # Push blank string here at Client tag
  newStr = system.tag.read("[client]Footer_Marquee.Value").value # Push blank string here at client tag
  s1 = system.tag.read("[default]"+str(LTSTDescription)+"/Footer/Message_FOOTER.Value").value
  s2 = system.tag.read("[default]"+str(LTSTDescription)+"/Footer/MessageMarquee.Value").value
  dispStr1 = dispStr[1:] + s1[0:]
  newStr2 = newStr[1:] + s2[0:]
  system.tag.write("[client]Footer_DisplayStr",dispStr1)
  system.tag.write("[client]Footer_Marquee",newStr2)

  system.tag.write("[client]Footer_IsConcat",1)
  system.tag.write("[client]Footer_Movement",0)

```

You should also consider reading all tags in one block rather than reading each tag separately as it’s far more efficient /faster.

---

<div class="post-metadata">

**Author:** ![Neha.kabra](https://avatars.discourse-cdn.com/v4/letter/n/e36b37/32.png) [@Neha.kabra](https://forum.inductiveautomation.com/u/Neha.kabra)\
**Post date:** [April 2, 2021, 4:33am UTC](https://forum.inductiveautomation.com/t/java-heap-space-error-giving-scattered-screen-on-clients/45162/6 "2021-04-02T04:33:02Z")

</div>

Thank you for responses. it is helpful.
