Bug 61376 - memory leak when using xterm control codes to write to titlebar
Summary: memory leak when using xterm control codes to write to titlebar
Status: RESOLVED WORKSFORME
Alias: None
Product: konsole
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: RedHat Enterprise Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Konsole Developer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-18 00:25 UTC by W. B. Maguire II
Modified: 2003-07-18 01:38 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description W. B. Maguire II 2003-07-18 00:25:44 UTC
Version:           Konsole 1.2 (KDE 3.1-11 Red Hat) (using KDE KDE 3.1)
Installed from:    RedHat RPMs
OS:          Linux

I used a Perl program from "Linux Server Hacks" to display the LoadAvg in my Konsole titlebar; result: a memory leak!  I verified that the control codes used to print to an XTERM titlebar are correct, and I verified that Konsole *should* accept these XTERM codes, and I wrote a small demonstration CSH script (below).

I'm wondering if this problem has not been noticed before, because---most commonly---a path (or something) is written to a titlebar upon a directory change.  It would take quite a few directory changes to notice the memory leak!  But, if you want to display the Load Average (or time) in the titlebar---and have it update every second or two---then the leak definitely becomes noticeable.

I observed this memory leak over a *long* period of time before I figured-out the root cause.  in fact, I even upgraded from RH8.0 to RH9, since the memory leak showed-up under the "kdeinit: kicker" process, I figured it was a Kicker bug.

-------------------------------------------
#!/bin/csh

# When I run this program on my system, I see the memory of the
# "kicker" process jump up by 4kB every 17-19 seconds!  I'm using the
# "pmap" program to monitor the "kicker" memory increase.

while (1)

   # The following is the REAL stuff I *wanted* in my titlebar:
   #
   #set loadavg = `cat /proc/loadavg | awk '{print $1,"   ",$2,"   ",$3}'`
   #set datetime = `date`
   #echo -n " ]2;$tty   $loadavg     $datetime"
   #
   # This is merely to demonstrate the memory leak that exists when
   # using XTERM control-character codes to print to the titlebar.
   # The memory leak shows-up in *kicker*!  The process has the name
   # "kdeinit: kicker" on my machine.
   #
   # ]0 => write to titlebar text and icon text
   # ]1 => write to icon text
   # ]2 => write to titlebar text
   #
   # Write 40 characters (not counting control characters)...
   #
   echo -n " ]2;1234567890123456789012345678901234567890"
   #
   # ...every second:
   #
   sleep 1

end
Comment 1 W. B. Maguire II 2003-07-18 00:30:25 UTC
Doh!! 
 
I forgot that the control codes wouldn't show-up.  The one at the BEGINNING of the 
string is an Esc, which you get by typing: CTRL-V Esc (octal 033, decimal 27).  The one 
at the END of the string is a Control-G, which you get by typing: CTRL-V CTRL-G (octal 
007, decimal 7). 
 
Thanks, 
Bruce. 
 
Comment 2 awendt 2003-07-18 00:55:11 UTC
You say that the memory leak shows up in Kicker... How do you know that it's a 
Konsole bug and not a Kicker bug? 
 
For example, that behaviour would make sense if Kicker leaks memory every time a 
window's title bar changes, perhaps during updating the taskbar. If you run your 
script inside KDE but from a normal xterm, does Kicker still leak memory? 
Comment 3 awendt 2003-07-18 01:19:42 UTC
I really think this is a Kicker bug. I could not get your script to cause Kicker to leak 
memory when run from a generic xterm, but I think xterm is smart enough not to reset 
the title if it is the same string as the one you sent last time. 
 
I can get Kicker's memory to grow if I run this script from an xterm, which adds an 
element of randomness to the title string to work around xterm being smart: 
 
#!/bin/bash 
while true; do 
  echo -ne "\033]2;${RANDOM}123456789012345678901234567890\007" 
done 
 
Comment 4 W. B. Maguire II 2003-07-18 01:24:57 UTC
Shoot!  Thanks for the help.

I'll go to my Linux box right now, and try it out for myself, but it certainly 
sounds like you are correct!  Double-Doh!  I can't believe that it did not 
occur to me that it really *could* be Kicker.

Thanks again.  If I get an XTerm to cause the same memory leak, then I will re-
submit this as a Kicker bug.

Bruce.
Comment 5 W. B. Maguire II 2003-07-18 01:38:19 UTC
Yep.  "awendt" was right!  This is, in fact, a Kicker bug, *not* a Konsole 
bug.  I'm sorry that I defamed the wonderful Konsole!  ;-)

Now, to move this baby to a *new* bug report under Kicker (after checking to 
make sure it's not already there somewhere!).

Sorry for the noise,
Bruce.