ActiveState Powered by ActiveState

ActiveState Community


spawn in ActivTcl causes memory leak?

Posted by hcchin on 2007-01-19 11:27

Hi,

I ran the following snippet on WinXP Pro/SP2 with ActiveTcl8.4.14.0.272572 installed. It is invoked from Command screen with tclsh. By looking at the Task Manager, the tclsh's memeory usage kept increasing and eventually the system run out of virtual memeoy. Anyone knos why?

=====================================================
package require Expect
exp_internal 1
set exp::winnt_debug 1
puts "Version: [info tclversion]"

while {1} {
set pid [exp_spawn ipconfig]
set id $spawn_id
puts "SID: $id"

expect {
"Mask" {
puts "FOUND Mask!!"
close -i $id
}
eof {
puts "EOF!!!"
}
}
}
======================================

Thanks for any response!

Jim

jeffh | Thu, 2007-08-09 12:02

As noted in the documentation, you should call exp_wait following the close to properly clean up resources.

bigstone1998 | Sun, 2007-11-25 23:10

There are still memory leakage, even after I use exp_wait after exp_close.
The script I tested is shown as following:
---------------------------
package require Expect
spawn ping 172.16.34.1
expect "Lost"
exp_close
exp_wait

---------------------------
after "package require Expect", the memory used by wish84.exe is 8,176 K
after exp_wait, the memory used by wish84.exe is 8,620K.

-------------------------------------
This is the output of the script run in wish shown above:

-----------------------------------
(bin) 1 % package require Expect
5.43
(bin) 2 % # now, the memory used by wish84.exe is 7,884 K
(bin) 3 % spawn ping 172.16.34.1
3796
(bin) 4 % expect "Lost"

Pinging 172.16.34.1 with 32 bytes of data:

Reply from 172.16.34.1: bytes=32 time<1ms TTL=63

Reply from 172.16.34.1: bytes=32 time<1ms TTL=63

Reply from 172.16.34.1: bytes=32 time<1ms TTL=63

Reply from 172.16.34.1: bytes=32 time<1ms TTL=63

Ping statistics for 172.16.34.1:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

(bin) 5 % exp_close
(bin) 6 % exp_wait
3796 exp2 0 0 {Can't read subprocess memory: ²Ù×÷³ɹ¦Íê³ɡ£
child process crashed.}
(bin) 7 %
----------------------------------------------

The OS system is :
WinXP2002, service pack 2
ActiveTcl8.4.15.0

============================
Thanks for any response :)

bigstone1998@sina.com

bigstone1998 | Tue, 2007-11-27 03:27

After try it more times, I found that after minimize the wish and console window, the memory will be decreased.

So, may be there are no memory leakage, but windows OS is playing some trick.

bigstone1998@sina.com

-->