Java Heap Space error giving scattered screen on clients

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

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).

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.

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.

1 Like

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

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.

Thank you for responses. it is helpful.