Subject: FVWM: FvwmScript scripts eating memory

From: Jason White <[email-masked]>
Date: Sun, 1 Dec 2002 00:48:46 -0600

I've recently started using FvwmScript and have noticed that a couple
fairly simple scripts I've written keep eating memory.  Having no idea
why and not finding any answers in the archives, I thought I'd ask here.
The scripts are available at:

 http://www.jdwhite.org/~jdwhite/FvwmApplet-BattMon
 http://www.jdwhite.org/~jdwhite/FvwmApplet-WLANMon

Any thoughts would be appreciated.
Thank you.

-- 
Jason White ([email-masked])  http://www.jdwhite.org/~jdwhite
AIM:jdwhite90125  Yahoo:jdwhite89  ICQ:9295078  MSN:[email-masked]
Jabber:[email-masked]  IRC:irc.netbsd.org/{jdwhite,jdw}
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Olivier Chapuis <[email-masked]>
Date: Sun, 1 Dec 2002 10:33:11 +0100

On Sun, Dec 01, 2002 at 12:48:46AM -0600, Jason White wrote:
> fairly simple scripts I've written keep eating memory.  

Yes. ChangeTitle leaks was fixed for 2.4.x but I forgot to fix
the Change{Fore,Back}Color was not (and ChangeIcon was only
partially fixed). This will be fixed in 2.4.15. Thanks

> Having no idea

There are workarounds.

For FvwmApplet-BattMon create 3 widgets with each the desired color
charging, ac-on, ac-off, then show/hide the widget depending
of the state.

A similar workaround can be used for WLANMon

Regards, Olivier

Here the modified version BattMon:

WindowTitle {FvwmApplet-BattMon}
WindowSize 70 25
#Font		-*-lucida-bold-r-normal-*-11-*-*-*-*-*-*
Font		-*-helvetica-bold-r-normal-*-12-*-*-*-*-*-*
# Use the FvwmScript default colors.
#BackColor {rgb:a0/90/80}
#ForeColor {black}
#ShadowColor	{black}
#HilightColor	{rgb:a0/90/80}

Init
 Begin
  Set $MainColorset=(GetScriptArgument 1)
  If $MainColorset <> {} Then
  Begin
   ChangeColorset 0 $MainColorset
   ChangeColorset 1 $MainColorset
   ChangeTitle 1 {BattMon}
  End
End

PeriodicTasks
 Begin
  If (RemainderOfDiv (GetTime) 5)==0 Then
  Begin
    Set $save_ac_bat = $ac_bat
    Set $save_charging = $charging
    Set $changed = 0
    Set $batcharge = (GetOutput {cat /proc/apm} 1 7)
    Set $remaining = (GetOutput {cat /proc/apm} 1 8)
    Set $ac_batt  =  (GetOutput {cat /proc/apm} 1 4)
    Set $charging =  (GetOutput {cat /proc/apm} 1 5)

    Set $remain_hrs = (Div $remaining 60)
    Set $raw_remain_min = (RemainderOfDiv $remaining 60)
    Set $cmd = {printf %02d }$raw_remain_min
    Set $remain_min = (GetOutput $cmd 1 -1)

    If $ac_batt <> $save_ac_batt Then
      Set $changed = 1
    If $save_charging <> $charging Then
      Set $changed = 1

    If $changed == 1 Then
    Begin
      If $ac_batt=={0x01} Then
      Begin
        # On AC power
        If $charging=={0x03} Then
        Begin
          ShowWidget 1
          HideWidget 2
          HideWidget 3
          #ChangeForeColor 1 {#ff0028}
        End
        Else
        Begin
          ShowWidget 2
          HideWidget 1
          HideWidget 3
	  #ChangeForeColor 1 {black}
        End
      End
      Else
      Begin
        ShowWidget 3
        HideWidget 1
        HideWidget 2  
        #ChangeForeColor 1 {#ff6400}
        #ChangeForeColor 1 {blue}
      End
    End
   
    Set $title = $batcharge{ }$remain_hrs{:}$remain_min
    If $save_title <> $title Then
    Begin
      Set $save_title= $title
      ChangeTitle 1 $title
      ChangeTitle 2 $title
      ChangeTitle 3 $title
   End
 End  
End

Widget 1
Property
 Position 0 0
 Size 70 25
 Type ItemDraw
 Flags NoReliefString
 Title {}
 ForeColor {#ff0028}
Main
 Case message of
  SingleClic :
  Begin
  End
End

Widget 2
Property
 Position 0 0
 Size 70 25
 Type ItemDraw
 Flags NoReliefString
 Title {}
 ForeColor {black} 
 Main
  Case message of
  SingleClic :
  Begin
  End
End

Widget 3
Property
 Position 0 0
 Size 70 25
 Type ItemDraw
 Flags NoReliefString
 Title {}
 ForeColor {blue}
 Main
  Case message of
  SingleClic :
  Begin
  End
 End