On Friday 25 February 2005 07:27, Dossy Shiobara wrote:
> On 2005.02.25, Andrew Piskorski <[EMAIL PROTECTED]> wrote:
> > Moving all tDOM auto-created procs into their own namespace would also
> > make solving the memory leak problem above easier, no?  Just remove
> > everything in that namespace when the conn ends.
>
> Absolutely.  Right now we do linear searches (read: SLOW AS CRAP) using
> stuff like this:
>
>     foreach proc [info proc domDoc*] {
>         rename proc {}
>     }
>

I'm using namespaces so cleanup is easy. Don't know how you would apply it to
your code, but creating a namespace for your commands and at the same time
registering a callback is the easiest solution. For example:

# ns_atclose wrapper. Must invoke once per connection
# to remove data from memory.
proc ::datastore::closeStore { store } {

    if {![info exists ::datastore::store::${store}::atClose]} {
        ns_atclose ::datastore::atClose $store
        namespace eval ::datastore::store::${store} { set atClose 1 }
    }
}

# callback procedure, invoked once conn closes or
# at end of scheduled procedure exec:
proc ::datastore::atClose { store } {

    if {[namespace exists ::datastore::store::${store}]} {
        namespace delete ::datastore::store::${store}
        log Notice "Closed store (memory delete) $store"
        return $store
    }
}

Not shown is the fact that closeStore is called when you create a datastore.
Any procs put into the namespace after this will be deleted regardless of
what happens to the conn.

tom jackson


--
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.

Reply via email to