Author Topic: PixelOverlay-Clock script slowly degrades and then stops  (Read 52 times)

Offline JonB256

  • Supporting Member
  • ******
  • Join Date: Mar 2013
  • Location: Granbury, Texas
  • Posts: 5,129
  • Kudos: 118
    • Granbury Christmas Lights
PixelOverlay-Clock script slowly degrades and then stops
« on: March 15, 2019, 08:04:26 AM »
On a small 2x2 P6 matrix, I am running the pixeloverlay-clock.pl script from the Repository.

I edited the script (from within the File Manager) to be centered, not scrolling, and then "Run" it from the same location.

Works great!  for about 4 hours. Then it starts skipping seconds and catching up. After about 8 hours or so, it will just freeze.

This is on a PocketBeagle (if that makes any difference) with Dan's PocketScroller mounted.

Code: [Select]
#!/usr/bin/perl
#############################################################################
# PixelOverlay-Clock.pl - Scroll a changing clock across a matrix
#############################################################################
# Set our library path to find the FPP Perl modules
use lib "/opt/fpp/lib/perl/";

# Use the FPP Memory Map module to talk to the daemon
use FPP::MemoryMap;

#############################################################################
# Setup some variables (this is the part you want to edit for font, color, etc.)
my $name  = "P6x4panel";    # Memory Mapped block name
my $color = "#00FF00";      # Text Color (also names like 'red', 'blue', etc.)
my $fill  = "#000000";      # Fill color (not used currently)
my $font  = "fixed";        # Font Name
my $size  = "16";           # Font size
my $pos   = "center";       # Position: 'scroll', 'center', 'x,y' (ie, '10,20')
my $dir   = "R2L";          # Scroll Direction: 'R2L', 'L2R', 'T2B', 'B2T'
my $pps   = 15;              # Pixels Per Second

#############################################################################
# This function will get called once per second and returns the text string
# to be displayed at that point in time.
sub GetNextMessage
{
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

$msg = sprintf("%02d:%02d:%02d", $hour, $min, $sec);

return $msg;
}

#############################################################################
# Main part of program

# Instantiate a new instance of the MemoryMap interface
my $fppmm = new FPP::MemoryMap;

# Open the maps
$fppmm->OpenMaps();

# Get info about the block we are interested in
my $blk   = $fppmm->GetBlockInfo($name);

# Clear the block, probably not necessary
$fppmm->SetBlockColor($blk, 0, 0, 0);

# Enable the block (pass 2 for transparent mode, or 3 for transparent RGB)
$fppmm->SetBlockState($blk, 1);

# Loop forever (ie, you'll need to CTRL-C to stop this script or kill it)
while (1) {
$fppmm->TextMessage($blk, \&GetNextMessage, $color, $fill, $font, $size, $pos, $dir, $pps);
}

# Disable the block
$fppmm->SetBlockState($blk, 0);

# Close the maps (shouldn't make it here with the above "while (1)" loop)
$fppmm->CloseMaps();

# Exit cleanly (shouldn't make it here with the above "while (1)" loop)
exit(0);

#############################################################################

Offline CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 9,737
  • Kudos: 205
Re: PixelOverlay-Clock script slowly degrades and then stops
« Reply #1 on: March 15, 2019, 09:34:45 AM »
Dan is currently rewriting a lot of this code and moving the functionality of the Perl module directly into fppd, so text writing will be done via a REST API call and the current Pixel Overlay scripts will need to be updated to work with the new code.   I haven't run the clock script long term, but there could be an issue with memory not being freed up automatically somewhere.  Users running the non-clock scripts may not notice for a lot longer time since those scripts don't change the image every second.

Can you login via ssh and run "ps auxw | grep YOURSCRIPTNAME" after starting the script and then run the same thing an hour or two later and see if the memory used is growing?  The memory number are in the 5th and 6th columns.  The 5th is the virtual memory mapped for the process and the 6th is the resident memory for the process, this is essentially how much real memory the process is taking.
-
Chris

Offline JonB256

  • Supporting Member
  • ******
  • Join Date: Mar 2013
  • Location: Granbury, Texas
  • Posts: 5,129
  • Kudos: 118
    • Granbury Christmas Lights
Re: PixelOverlay-Clock script slowly degrades and then stops
« Reply #2 on: March 15, 2019, 10:48:10 AM »
Thanks, Chris.  You did make me learn a bit about REST APIs and their usage.

I do see memory numbers creeping up in a PuTTy window but won't be home around the time I expect it to have problems. Will have to wait until Monday.

here is what I'm seeing so far, though (about one hour of run time)
Memory usage on the "about" page is slowly creeping up, also.

Code: [Select]
fpp@PocketScroller:~$ ps aux2 | grep PixelOverlay-Clock.pl
fpp      11525  0.0  0.1   1432   972 ?        S    10:46   0:00 sh -c sudo /opt/fpp/scripts/eventScript /home/fpp/media/scripts/PixelOverlay-Clock.pl
root     11526  0.0  0.4   4624  2440 ?        S    10:46   0:00 sudo /opt/fpp/scripts/eventScript /home/fpp/media/scripts/PixelOverlay-Clock.pl
root     11527 95.4 16.5 116808 82072 ?        R    10:46   1:41 /usr/bin/perl /home/fpp/media/scripts/PixelOverlay-Clock.pl
fpp      11551  0.0  0.3   3764  1640 pts/0    S+   10:48   0:00 grep PixelOverlay-Clock.pl
fpp@PocketScroller:~$ ps aux2 | grep PixelOverlay-Clock.pl
fpp      11525  0.0  0.1   1432   972 ?        S    10:46   0:00 sh -c sudo /opt/fpp/scripts/eventScript /home/fpp/media/scripts/PixelOverlay-Clock.pl
root     11526  0.0  0.4   4624  2440 ?        S    10:46   0:00 sudo /opt/fpp/scripts/eventScript /home/fpp/media/scripts/PixelOverlay-Clock.pl
root     11527 94.8 16.7 117760 83020 ?        R    10:46   3:33 /usr/bin/perl /home/fpp/media/scripts/PixelOverlay-Clock.pl
fpp      11649  0.0  0.3   3764  1516 pts/0    S+   10:50   0:00 grep PixelOverlay-Clock.pl
fpp@PocketScroller:~$ ps aux2 | grep PixelOverlay-Clock.pl
fpp      11525  0.0  0.1   1432   972 ?        S    10:46   0:00 sh -c sudo /opt/fpp/scripts/eventScript /home/fpp/media/scripts/PixelOverlay-Clock.pl
root     11526  0.0  0.4   4624  2440 ?        S    10:46   0:00 sudo /opt/fpp/scripts/eventScript /home/fpp/media/scripts/PixelOverlay-Clock.pl
root     11527 91.7 20.2 135416 100716 ?       R    10:46  41:10 /usr/bin/perl /home/fpp/media/scripts/PixelOverlay-Clock.pl
fpp      11826  0.0  0.3   3764  1584 pts/0    S+   11:31   0:00 grep PixelOverlay-Clock.pl
fpp@PocketScroller:~$ ps aux2 | grep PixelOverlay-Clock.pl
fpp      11525  0.0  0.1   1432   972 ?        S    10:46   0:00 sh -c sudo /opt/fpp/scripts/eventScript /home/fpp/media/scripts/PixelOverlay-Clock.pl
root     11526  0.0  0.4   4624  2440 ?        S    10:46   0:00 sudo /opt/fpp/scripts/eventScript /home/fpp/media/scripts/PixelOverlay-Clock.pl
root     11527 92.1 20.9 138800 104060 ?       R    10:46  46:10 /usr/bin/perl /home/fpp/media/scripts/PixelOverlay-Clock.pl
fpp      11896  0.0  0.3   3764  1612 pts/0    S+   11:36   0:00 grep PixelOverlay-Clock.pl
fpp@PocketScroller:~$ ps aux2 | grep PixelOverlay-Clock.pl
fpp      11525  0.0  0.1   1432   972 ?        S    10:46   0:00 sh -c sudo /opt/fpp/scripts/eventScript /home/fpp/media/scripts/PixelOverlay-Clock.pl
root     11526  0.0  0.4   4624  2440 ?        S    10:46   0:00 sudo /opt/fpp/scripts/eventScript /home/fpp/media/scripts/PixelOverlay-Clock.pl
root     11527 92.3 21.2 140364 105664 ?       R    10:46  49:45 /usr/bin/perl /home/fpp/media/scripts/PixelOverlay-Clock.pl
fpp      11960  0.0  0.3   3764  1672 pts/0    S+   11:40   0:00 grep PixelOverlay-Clock.pl

Offline CaptainMurdoch

  • Administrator
  • *****
  • Join Date: Sep 2013
  • Location: Washington
  • Posts: 9,737
  • Kudos: 205
Re: PixelOverlay-Clock script slowly degrades and then stops
« Reply #3 on: March 15, 2019, 02:54:33 PM »
So in less than an hour running, the memory utilization went up by 20MBytes.  That doesn't look good if it is a consistent pattern.

I will take another look at the perl module to see if there is anything we could be doing to prevent that.  I glanced at it earlier, but since most of that code hasn't been touched in years I didn't glance long enough to totally refresh my memory on all the aspects of it.

 

Back to top