Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Temp var leak in compiled Tcl8.0p2???

7 views
Skip to first unread message

Wolf-Dietrich Ihlenfeldt

unread,
Apr 13, 1998, 3:00:00 AM4/13/98
to

Hello Tcl-Experts,

I have the following problem with tcl8.0p2 on IRIX6.3:

I am calling from C (via Tcl_EvalObj, no change if I
use Tcl_GlobalEvalObj or plain Tcl_Eval/GlobalEval)
several thousand times a Tcl procedure (which does
not change between invoactions). The procedure interpreter
is a slave of the main interpreter, in case this matters,
and contains only standard Tcl/TclX commands/functions plus
this one procedure and some more custom C-commands.
All custom C commands still use the argc/argv-argument passing.
The whole thing happens while the
main interpreter executes a script, calls my C code
via custom commands, which again call out to the Tcl proc in
the specialized slave interpreter. The specialized slave interpreter
is not used for any other activity.
Very soon the execution time of the proc becomes much longer.
The reason is that the interpreter spends more and more
time in TclLookupVar(), more precisely in the
loop between line 267 and 279, where variables are looked
up among the compiled locals. The loop takes longer because
every call to the proc via TclEvalxxx() seems to leave about 15 vars in this
list. This coincides with the total number of vars used in
the proc, but this may be a random coincidence.
After a short time, thousands of temp vars (the isTemp flag
is set) accumulate and everything becomes very slow - but
other than that, the results are still correct.

The same procedure performs flawlessly under Tcl7.6, with
the same call sequence and everything, except that it is
linked with the older Tcl version, and does not use a
slave interpreter for execution, using the main interpreter
instead.

A typical fingerprint of one of these var entries:

struct CompiledLocal {
nextPtr = 0x100d6e58
nameLength = 0
frameIndex = 1825
isArg = 0
isTemp = 1
flags = 1
defValuePtr = (nil)
name = ""
}

with localCt = 2767


What is the reason for this behaviour? Is this a
bug (and if yes, has anybody a patch for it?),
or should I perform some cleanup action to get rid of these temp vars?


Here is the proc definition which causes this behaviour:

------


# property computation function for E_SCREEN property
# prop is defined in the standard prop set

# current default length of screen is 305 bits
# with extensions 559 bits

proc get_screen {ehandle} {
set stdsym [list H LI B C N O F NA SI P S CL K BR I BE MG AL CA SC TI V CR MN FE CO NI CU ZN GA GE AS SE KR RB SR Y ZR NB MO RU RH PD AG CD IN SN SB TE XE CS BA LU HF TA W RE OS IR PT AU HG TL PB BI LA CE PR ND PM SM EU GD TB DY HO ER TM YB]
set stdmin [list 4 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
set stdmax [list 64 2 4 64 8 16 4 2 2 4 8 8 2 4 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
foreach sym $stdsym { set symcnt($sym) 0 }
foreach sym [string toupper [ens get $ehandle A_SYMBOL]] {
catch {incr symcnt($sym) }
}
foreach sym $stdsym max $stdmax min $stdmin {
foreach cnt [list 1 2 4 8 16 32] {
if {$cnt<$min} continue
if {$cnt>$max} break
append l [expr {$symcnt($sym)>=$cnt}]
# puts "Element $sym cnt >= $cnt [expr {$symcnt($sym)>=$cnt}]"
}
}
#puts "[clength $l] with element counts"

loop rsize 3 9 { set rcnt($rsize) 0}
set naro [llength [ens get $ehandle R_SIZE aromatic]]
foreach rsize [ens get $ehandle R_SIZE] {
catch {incr rcnt($rsize) }
}
foreach rsize [list 3 4 5 6 7 8] limit [list 2 2 5 5 2 2] {
loop cnt 1 6 {
if {$cnt>$limit} break
append l [expr {$rcnt($rsize)>=$cnt}]
# puts "Ring: size $rsize cnt $cnt [expr {$rcnt($rsize)>=$cnt}]"
}
}
loop i 1 5 {
append l [expr {$naro>=$i}]
# puts "Aro: cnt>=$i [expr {$naro>=$i}]"
}
#puts "[clength $l] with ring counts"

set frags [list \
li-h \
li-li \
li-b \
li-c \
li-o \
li-f \
li-p \
li-s \
li-cl \
b-h \
b-b \
b-c \
b-n \
b-o \
b-f \
b-si \
b-p \
b-s \
b-cl \
b-br \
c-h \
c-c \
c-n \
c-o \
c-f \
c-na \
c-mg \
c-al \
c-si \
c-p \
c-s \
c-cl \
c-as \
c-se \
c-br \
c-i \
n-h \
n-n \
n-o \
n-f \
n-si \
n-p \
n-s \
n-cl \
n-br \
o-h \
o-o \
o-mg \
o-na \
o-al \
o-si \
o-p \
o-k \
f-p \
f-s \
al-h \
al-cl \
si-h \
si-si \
si-cl \
p-h \
p-p \
as-h \
as-as \
]
append l [eval screen $ehandle $frags]
#puts "[clength $l] with 2-atom screens"

set frags [list \
c(-br)(-c) \
c(-br)(-c)(-c) \
c(-br)(-h) \
c(-br)(~c) \
c(-br)(~n) \
c(-c)(-c) \
c(-c)(-c)(-c) \
c(-c)(-c)(-c)(-c) \
c(-c)(-c)(-c)(-h) \
c(-c)(-c)(-c)(-n) \
c(-c)(-c)(-c)(-o) \
c(-c)(-c)(-h)(-n) \
c(-c)(-c)(-h)(-o) \
c(-c)(-c)(-n) \
c(-c)(-c)(-o) \
c(-c)(-cl) \
c(-c)(-cl)(-h) \
c(-c)(-h) \
c(-c)(-h)(-n) \
c(-c)(-h)(-o) \
c(-c)(-h)(-o)(-o) \
c(-c)(-h)(-p) \
c(-c)(-h)(-s) \
c(-c)(-i) \
c(-c)(-n) \
c(-c)(-o) \
c(-c)(-s) \
c(-c)(-si) \
c(-c)(~c) \
c(-c)(~c)(~c) \
c(-c)(~c)(~n) \
c(-c)(~n) \
c(-c)(~n)(~n) \
c(-cl)(-cl) \
c(-cl)(-h) \
c(-cl)(~c) \
c(-f)(-f) \
c(-f)(~c) \
c(-h)(-n) \
c(-h)(-o) \
c(-h)(-o)(-o) \
c(-h)(-s) \
c(-h)(-si) \
c(-h)(~c) \
c(-h)(~c)(~c) \
c(-h)(~c)(~n) \
c(-h)(~n) \
c(-h)(-h)(-h) \
c(-n)(-n) \
c(-n)(~c) \
c(-n)(~c)(~c) \
c(-n)(~c)(~n) \
c(-n)(~n) \
c(-o)(-o) \
c(-o)(~c) \
c(-o)(~c)(~c) \
c(-s)(~c) \
c(~c)(~c) \
c(~c)(~c)(~c) \
c(~c)(~c)(~n) \
c(~c)(~n) \
c(~c)(~n)(~n) \
c(~n)(~n) \
n(-c)(-c) \
n(-c)(-c)(-c) \
n(-c)(-c)(-h) \
n(-c)(-h) \
n(-c)(-h)(-n) \
n(-c)(-o) \
n(-c)(~c) \
n(-c)(~c)(~c) \
n(-h)(-n) \
n(-h)(~c) \
n(-h)(~c)(~c) \
n(-o)(-o) \
n(-o)(~o) \
n(~c)(~c) \
n(~c)(~c)(~c) \
o(-c)(-c) \
o(-c)(-h) \
o(-c)(-p) \
o(-h)(-s) \
o(~c)(~c) \
p(-c)(-c) \
p(-o)(-o) \
s(-c)(-c) \
s(-c)(-h) \
s(-c)(-o) \
si(-c)(-c) \
]

append l [eval screen -ligands $ehandle $frags]
#puts "[clength $l] bo-independent"
set frags [list \
c=c \
c*c \
c=n \
c*n \
c=o \
c=s \
n=n \
n=o \
n=p \
c=o \
p=p \
c(*c)(-c) \
c(*c)(-h) \
c(*n)(-c) \
c(-c)(-c)(=c) \
c(-c)(-c)(=n) \
c(-c)(-c)(=o) \
c(-c)(-cl)(=o) \
c(-c)(-h)(=c) \
c(-c)(-h)(=n) \
c(-c)(-h)(=o) \
c(-c)(-n)(=c) \
c(-c)(-n)(=n) \
c(-c)(-n)(=o) \
c(-c)(-o)(=o) \
c(-c)(=c) \
c(-c)(=n) \
c(-c)(=o) \
c(-cl)(=o) \
c(-h)(-n)(=c) \
c(-h)(=c) \
c(-h)(=n) \
c(-h)(=o) \
c(-n)(=c) \
c(-n)(=n) \
c(-n)(=o) \
c(-o)(=o) \
n(-c)(=c) \
n(-c)(=o) \
n(-o)(=o) \
p(-o)(=o) \
s(-c)(=o) \
s(-o)(=o) \
s(=o)(=o) \
]
append l [eval screen -ligands $ehandle $frags]

#puts "[clength $l] with everything (should be 305)"


if {[prop getparam E_SCREEN extended 0 0]} {
set frags [list \
C-C-C#C \
O-C-C=N \
O-C-C=O \
N~C-S-\[H\] \
N-C-C=C \
O=S-C-C \
N#C-C=C \
C=N-N-C \
O=S-C-N \
S-S-C~C \
C#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N-C-C \
C-N-C~C-C \
C-C-S-C-C \
O-C-C-N-C \
C-C=C-C-C \
O-C-O-C-C \
O-C-C-O-C \
O-C-C-O-\[H\] \
C-C=C-C=C \
N-C~C-C-C \
C=C-C-O-C \
C=C-C-O-\[H\] \
C-C~C-C-C \
Cl-C~C-C=O \
Br-C~C~C-C \
O=C-C=C-C \
O=C-C=C-\[H\] \
O=C-C=C-N \
N-C-N-C~C \
Br-C-C-C~C \
N#C-C-C-C \
C-C=C-C~C \
C-C-C=C-C \
C-C-C-C-C-C \
O-C-C-C-C-C \
O-C-C-C-C-O \
O-C-C-C-C-N \
N-C-C-C-C-C \
O=C-C-C-C-C \
O=C-C-C-C-N \
O=C-C-C-C-O \
O=C-C-C-C=O \
C-C-C-C-C-C-C \
O-C-C-C-C-C-C \
O-C-C-C-C-C-O \
O-C-C-C-C-C-N \
O=C-C-C-C-C-C \
O=C-C-C-C-C-O \
O=C-C-C-C-C=O \
O=C-C-C-C-C-N \
C-C-C-C-C-C-C-C \
C-C-C-C-C-C(C)-C \
O-C-C-C-C-C-C-C \
O-C-C-C-C-C(C)-C \
O-C-C-C-C-C-O-C \
O-C-C-C-C-C(O)-C \
O-C-C-C-C-C-N-C \
O-C-C-C-C-C(N)-C \
O=C-C-C-C-C-C-C \
O=C-C-C-C-C(O)-C \
O=C-C-C-C-C(=O)-C \
O=C-C-C-C-C(N)-C \
C-C(C)-C-C \
C-C(C)-C-C-C \
C-C-C(C)-C-C \
C-C(C)(C)-C-C \
C-C(C)-C(C)-C \
]
append l [eval screen -smiles $ehandle $frags]
}

ens set $ehandle E_SCREEN $l

return $l
}

--
Dr. Wolf-D. Ihlenfeldt
Computer Chemistry Center, University of Erlangen-Nuernberg
Naegelsbachstrasse 25, D-91052 Erlangen (Germany)
Tel (+49)-(0)9131-85-6579 Fax (+49)-(0)9131-85-6566
---
The three proven methods for ultimate success and fame:
1) Nakanu nara koroshite shimae hototogisu
2) Nakanu nara nakasete miseyou hototogisu
3) Nakanu nara naku made matou hototogisu

Conor Williams

unread,
Oct 15, 2021, 9:20:44 AM10/15/21
to
hi Wolf-D Ihlenfeldt
Did you get this going?
Kind Regards
/c:20211510
0 new messages