Agustin Lopez schrieb:
Any pointer to detect where the memory is losing?
To this rate of loss the server (from 1 - 10 MB per minute) only holds 2 days
of uptime.
Well, this means, it runs perfectly, when you reboot it manually every
night and the
traffic is not increasing... (just joking)
i have written the following script to help to find "application level
leaks",
such as every growing variables, associative arrays, etc. It sould give
you a rough idea what is using which memory in your application. It is
not measuring
the tcl overhead (memory footprint of namespaces, variables, commands)
or e.g.
nsvs. It might be useful to detect, when an application creates
namespaces and leaves
growing variables there. Actually, the script must be run in each
interpreter, since
these might have different states (e.g. source the script via ns_eval).
Look for differences between interpreters and differences over time.
best regards
-gustaf neumann
----------------------
# script to determine application level leaks
# -gustaf neumann
proc report {} {
set ps [exec ps xv | grep "^[pid] "]
set vsz [lindex $ps 6]
set result ""
array set total {vars 0 procs 0 cmds 0 array_elements 0 var_bytes 0}
set details [lindex [__report__ns ::] 0]
foreach l $details {
array set tmp $l
foreach e [array names total] {incr total($e) $tmp($e)}
append result $l\n
}
return "$result\nTOTAL: pid [pid] vsz $vsz namespaces [llength
$details] [array get total]"
}
proc __report__ns {ns} {
if {$ns eq "::dom::domNode" ||
$ns eq "::dom::domDoc"} {
set result [list [list ns $ns]]
} else {
set pattern [expr {$ns eq "::" ? "::*" : "${ns}::*"}]
set nrvars [llength [info vars $pattern]]
set elements 0
set bytes 0
foreach var [info vars $pattern] {
if {[array exists $var]} {
incr elements [array size $var]
foreach e [array names $var] {incr bytes [string length ${var}($e)]}
} else {
incr bytes [string length $var]
}
}
set nrprocs [llength [info procs $pattern]]
set nrcmds [llength [info commands $pattern]]
incr nrcmds -$nrprocs
set result [list [list ns $ns vars $nrvars procs $nrprocs cmds
$nrcmds \
array_elements $elements var_bytes $bytes]]
}
foreach nc [lsort [namespace children $ns]] {
if {$nc eq "::xotcl::classes"} continue
foreach l [__report__ns $nc] {eval lappend result $l}
}
return [list $result]
}
ns_log notice [report]
--
AOLserver - http://www.aolserver.com/
To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]>
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject:
field of your email blank.